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.

IEditAboutTelsService.cs 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. using Karsha_Site.Application.Interfaces.Contexts;
  2. using Karsha_Site.Common.Dto;
  3. using Microsoft.AspNetCore.Hosting;
  4. using Microsoft.AspNetCore.Http;
  5. using Microsoft.EntityFrameworkCore;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. namespace Karsha_Site.Application.Services.Costomers.Commands.EditAboutTels
  12. {
  13. public interface IEditAboutTelsService
  14. {
  15. ResultDto Execute(RequestEditaboutTelsDto request);
  16. }
  17. public class EditAboutTelsService : IEditAboutTelsService
  18. {
  19. private readonly IDataBaseContext _dataBaseContext;
  20. public EditAboutTelsService(IDataBaseContext context)
  21. {
  22. _dataBaseContext = context;
  23. }
  24. ResultDto IEditAboutTelsService.Execute(RequestEditaboutTelsDto request)
  25. {
  26. var aboutTels = _dataBaseContext.AboutTels.Find(request.ID);
  27. if (aboutTels == null)
  28. {
  29. return new ResultDto
  30. {
  31. IsSuccess = false,
  32. Message = "تلفن یافت نشد"
  33. };
  34. }
  35. aboutTels.IsMain = request.IsMain;
  36. aboutTels.TelNo = request.TelNo;
  37. aboutTels.Title = request.Title;
  38. aboutTels.UpdateTime = DateTime.Now;
  39. _dataBaseContext.SaveChanges();
  40. return new ResultDto()
  41. {
  42. IsSuccess = true,
  43. Message = "ویرایش تلفن انجام شد"
  44. };
  45. }
  46. }
  47. public class RequestEditaboutTelsDto
  48. {
  49. public int ID { get; set; }
  50. public string Title { get; set; }
  51. public int TelNo { get; set; }
  52. public bool IsMain { get; set; }
  53. public int AboutID { get; set; }
  54. }
  55. }