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

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