You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

IInsertAboutServise.cs 1.9KB

2 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. 
  2. using Karsha_Site.Application.Interfaces.Contexts;
  3. using Karsha_Site.Common.Dto;
  4. using Karsha_Site.Domain.Entities.About;
  5. using Microsoft.AspNetCore.Hosting;
  6. using Microsoft.AspNetCore.Http;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.IO;
  10. using System.Linq;
  11. using System.Text;
  12. using System.Threading.Tasks;
  13. namespace Karsha_Site.Application.Services.About.Commands.InsetAbout
  14. {
  15. public interface IInsertAboutServise
  16. {
  17. ResultDto<ResultInsertAboutDto> Execute(RequestInsertAboutDto request);
  18. }
  19. public class InsertCustomersServise : IInsertAboutServise
  20. {
  21. private readonly IHostingEnvironment _environment;
  22. private readonly IDataBaseContext _dataBaseContext;
  23. public InsertCustomersServise(IDataBaseContext context, IHostingEnvironment hostingEnvironment)
  24. {
  25. _dataBaseContext = context;
  26. _environment = hostingEnvironment;
  27. }
  28. public ResultDto<ResultInsertAboutDto> Execute(RequestInsertAboutDto request)
  29. {
  30. var about = new AboutUs
  31. {
  32. Description = request.Description,
  33. Email = request.Email,
  34. Instagram = request.Instagram,
  35. PostiCode= request.PostiCode,
  36. PostiSandogh = request.PostiSandogh,
  37. Title = request.Title,
  38. };
  39. about.InsertTime = DateTime.Now;
  40. _dataBaseContext.Abouts.Add(about);
  41. _dataBaseContext.SaveChanges();
  42. return new ResultDto<ResultInsertAboutDto>(){
  43. Data = new ResultInsertAboutDto()
  44. {
  45. AboutId = about.ID
  46. },
  47. IsSuccess = true,
  48. Message = "اطلاعات با موفقیت ثبت شد"
  49. };
  50. }
  51. }
  52. public class RequestInsertAboutDto
  53. {
  54. public int AboutId { get; set; }
  55. public string Title { get; set; }
  56. public string Description { get; set; }
  57. public int? PostiCode { get; set; }
  58. public int? PostiSandogh { get; set; }
  59. public string Email { get; set; }
  60. public string Instagram { get; set; }
  61. }
  62. public class ResultInsertAboutDto
  63. {
  64. public int AboutId { get; set; }
  65. }
  66. }