您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

CustomerController.cs 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. using Karsha_Site.Application.Services.Costomers.Queries.GetCustomers;
  2. using Karsha_Site.Application.Services.Costomers.Commands.InsetCustomers;
  3. using Microsoft.AspNetCore.Mvc;
  4. using System.Collections.Generic;
  5. using Microsoft.AspNetCore.Http;
  6. using Karsha_Site.Application.Services.Costomers.Commands.EditCustomers;
  7. using Karsha_Site.Application.Services.Costomers.Commands.RemoveCustomers;
  8. namespace EndPoint.Site.Areas.Admin.Controllers
  9. {
  10. [Area("Admin")]
  11. public class CustomerController : Controller
  12. {
  13. private readonly IGetAboutAddressServise _getCustomersService;
  14. private readonly IInsertCustomersServise _insertCustomersService;
  15. private readonly IEditCustomersService _editCustomersService;
  16. private readonly IRemoveCategoriesService _removeCustomersServise;
  17. public CustomerController(IGetAboutAddressServise customersService,
  18. IInsertCustomersServise insertCustomersService, IEditCustomersService editCustomersService, IRemoveCategoriesService removeCustomersServise)
  19. {
  20. _getCustomersService = customersService;
  21. _insertCustomersService = insertCustomersService;
  22. _editCustomersService = editCustomersService;
  23. _removeCustomersServise = removeCustomersServise;
  24. }
  25. public IActionResult Index(string searchKey,int page=1, int PageSize = 10)
  26. {
  27. return View(_getCustomersService.Execute(new RequestGetAboutAddressDto
  28. {
  29. Page = page,
  30. SearchKey = searchKey,
  31. PageSize = PageSize
  32. }));
  33. }
  34. [HttpGet]
  35. public IActionResult Create()
  36. {
  37. return View();
  38. }
  39. [HttpPost]
  40. public IActionResult Create(RequestInsertCustomerDto request)
  41. {
  42. var result = _insertCustomersService.Execute(new RequestInsertCustomerDto
  43. {
  44. Address = request.Address,
  45. FullName = request.FullName,
  46. Image = request.Image,
  47. Link = request.Link,
  48. });
  49. return Json(result);
  50. }
  51. [HttpPost]
  52. public IActionResult Delete(int CustomerId)
  53. {
  54. return Json(_removeCustomersServise.Execute(CustomerId));
  55. }
  56. [HttpPost]
  57. public IActionResult Edit(int CustomerId, string Fullname, string Address, string Link)
  58. {
  59. return Json(_editCustomersService.Execute(new RequestEditCustomerDto
  60. {
  61. FullName = Fullname,
  62. ID = CustomerId,
  63. Address = Address,
  64. Link = Link
  65. }));
  66. }
  67. }
  68. }