123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- using Karsha_Site.Application.Services.Costomers.Queries.GetCustomers;
- using Karsha_Site.Application.Services.Costomers.Commands.InsetCustomers;
- using Microsoft.AspNetCore.Mvc;
- using System.Collections.Generic;
- using Microsoft.AspNetCore.Http;
- using Karsha_Site.Application.Services.Costomers.Commands.EditCustomers;
- using Karsha_Site.Application.Services.Costomers.Commands.RemoveCustomers;
-
- namespace EndPoint.Site.Areas.Admin.Controllers
- {
- [Area("Admin")]
- public class CustomerController : Controller
- {
- private readonly IGetAboutAddressServise _getCustomersService;
- private readonly IInsertCustomersServise _insertCustomersService;
- private readonly IEditCustomersService _editCustomersService;
- private readonly IRemoveCategoriesService _removeCustomersServise;
-
-
- public CustomerController(IGetAboutAddressServise customersService,
- IInsertCustomersServise insertCustomersService, IEditCustomersService editCustomersService, IRemoveCategoriesService removeCustomersServise)
- {
- _getCustomersService = customersService;
- _insertCustomersService = insertCustomersService;
- _editCustomersService = editCustomersService;
- _removeCustomersServise = removeCustomersServise;
- }
-
- public IActionResult Index(string searchKey,int page=1, int PageSize = 10)
- {
- return View(_getCustomersService.Execute(new RequestGetAboutAddressDto
- {
- Page = page,
- SearchKey = searchKey,
- PageSize = PageSize
- }));
- }
- [HttpGet]
- public IActionResult Create()
- {
- return View();
- }
- [HttpPost]
- public IActionResult Create(RequestInsertCustomerDto request)
- {
- var result = _insertCustomersService.Execute(new RequestInsertCustomerDto
- {
- Address = request.Address,
- FullName = request.FullName,
- Image = request.Image,
- Link = request.Link,
- });
- return Json(result);
- }
-
- [HttpPost]
- public IActionResult Delete(int CustomerId)
- {
- return Json(_removeCustomersServise.Execute(CustomerId));
- }
-
- [HttpPost]
- public IActionResult Edit(int CustomerId, string Fullname, string Address, string Link)
- {
- return Json(_editCustomersService.Execute(new RequestEditCustomerDto
- {
- FullName = Fullname,
- ID = CustomerId,
- Address = Address,
- Link = Link
- }));
- }
- }
- }
|