добавил контроллеры в рестапи
This commit is contained in:
parent
f173a6b4a8
commit
7611610ba2
@ -1,82 +1,106 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using BeautySalonContracts.BindingModels;
|
||||
using BeautySalonContracts.BusinessLogicContracts;
|
||||
using BeautySalonContracts.SearchModels;
|
||||
using BeautySalonContracts.ViewModels;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace BeatySalonRestApi.Controllers
|
||||
namespace BeautySalonRestApi.Controllers
|
||||
{
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
public class CosmeticController : Controller
|
||||
{
|
||||
// GET: CosmeticController
|
||||
public ActionResult Index()
|
||||
private readonly ILogger logger;
|
||||
|
||||
private readonly ICosmeticLogic cosmetic;
|
||||
|
||||
public CosmeticController(ILogger<CosmeticController> logger, ICosmeticLogic cosmetic)
|
||||
{
|
||||
return View();
|
||||
this.logger = logger;
|
||||
this.cosmetic = cosmetic;
|
||||
}
|
||||
|
||||
// GET: CosmeticController/Details/5
|
||||
public ActionResult Details(int id)
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
// GET: CosmeticController/Create
|
||||
public ActionResult Create()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
// POST: CosmeticController/Create
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public ActionResult Create(IFormCollection collection)
|
||||
[HttpGet]
|
||||
public CosmeticViewModel? Get(int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
return RedirectToAction(nameof(Index));
|
||||
return cosmetic.ReadElement(new CosmeticSearchModel { Id = id });
|
||||
}
|
||||
catch
|
||||
catch (Exception ex)
|
||||
{
|
||||
return View();
|
||||
logger.LogError(ex, "Ошибка получения косметики с id = {Id}", id);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
// GET: CosmeticController/Edit/5
|
||||
public ActionResult Edit(int id)
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
// POST: CosmeticController/Edit/5
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public ActionResult Edit(int id, IFormCollection collection)
|
||||
[HttpGet]
|
||||
public List<CosmeticViewModel>? GetAll()
|
||||
{
|
||||
try
|
||||
{
|
||||
return RedirectToAction(nameof(Index));
|
||||
return cosmetic.ReadList(null);
|
||||
}
|
||||
catch
|
||||
catch (Exception ex)
|
||||
{
|
||||
return View();
|
||||
logger.LogError(ex, "Ошибка получения списка косметики");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
// GET: CosmeticController/Delete/5
|
||||
public ActionResult Delete(int id)
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
// POST: CosmeticController/Delete/5
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public ActionResult Delete(int id, IFormCollection collection)
|
||||
[HttpGet]
|
||||
public List<CosmeticViewModel>? GetMany(int userId, int page)
|
||||
{
|
||||
try
|
||||
{
|
||||
return RedirectToAction(nameof(Index));
|
||||
return cosmetic.ReadList(new CosmeticSearchModel { LaborCostId = userId });
|
||||
}
|
||||
catch
|
||||
catch (Exception ex)
|
||||
{
|
||||
return View();
|
||||
logger.LogError(ex, "Ошибка получения списка косметики клиента id = {Id}", userId);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void Create(CosmeticBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
cosmetic.Create(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError(ex, "Ошибка создания косметики");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void Update(CosmeticBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
cosmetic.Update(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError(ex, "Ошибка обновления косметики");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void Delete(CosmeticBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
cosmetic.Delete(new() { Id = model.Id });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError(ex, "Ошибка удаления косметики");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,82 +1,120 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using BeautySalonContracts.BindingModels;
|
||||
using BeautySalonContracts.BusinessLogicContracts;
|
||||
using BeautySalonContracts.SearchModels;
|
||||
using BeautySalonContracts.ViewModels;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace BeatySalonRestApi.Controllers
|
||||
namespace BeautySalonRestApi.Controllers
|
||||
{
|
||||
public class LaborCostController : Controller
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
public class LaborCostsController : Controller
|
||||
{
|
||||
// GET: LaborCost
|
||||
public ActionResult Index()
|
||||
private readonly ILogger logger;
|
||||
|
||||
private readonly ILaborCostsLogic laborCosts;
|
||||
|
||||
public LaborCostsController(ILogger<LaborCostsController> logger, ILaborCostsLogic laborCosts)
|
||||
{
|
||||
return View();
|
||||
this.logger = logger;
|
||||
this.laborCosts = laborCosts;
|
||||
}
|
||||
|
||||
// GET: LaborCost/Details/5
|
||||
public ActionResult Details(int id)
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
// GET: LaborCost/Create
|
||||
public ActionResult Create()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
// POST: LaborCost/Create
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public ActionResult Create(IFormCollection collection)
|
||||
[HttpGet]
|
||||
public LaborCostsViewModel? Get(int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
return RedirectToAction(nameof(Index));
|
||||
return laborCosts.ReadElement(new LaborCostsSearchModel { Id = id });
|
||||
}
|
||||
catch
|
||||
catch (Exception ex)
|
||||
{
|
||||
return View();
|
||||
logger.LogError(ex, "Ошибка получения трудозатраты с id = {Id}", id);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
// GET: LaborCost/Edit/5
|
||||
public ActionResult Edit(int id)
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
// POST: LaborCost/Edit/5
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public ActionResult Edit(int id, IFormCollection collection)
|
||||
[HttpGet]
|
||||
public List<LaborCostsViewModel>? GetAll()
|
||||
{
|
||||
try
|
||||
{
|
||||
return RedirectToAction(nameof(Index));
|
||||
return laborCosts.ReadList(null);
|
||||
}
|
||||
catch
|
||||
catch (Exception ex)
|
||||
{
|
||||
return View();
|
||||
logger.LogError(ex, "Ошибка получения списка трудозатрат");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
// GET: LaborCost/Delete/5
|
||||
public ActionResult Delete(int id)
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
// POST: LaborCost/Delete/5
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public ActionResult Delete(int id, IFormCollection collection)
|
||||
[HttpGet]
|
||||
public List<LaborCostsViewModel>? GetAllByUser(int userId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return RedirectToAction(nameof(Index));
|
||||
return laborCosts.ReadList(new LaborCostsSearchModel { StaffMemberId = userId });
|
||||
}
|
||||
catch
|
||||
catch (Exception ex)
|
||||
{
|
||||
return View();
|
||||
logger.LogError(ex, "Ошибка получения списка трудозатрат пользователя");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public List<LaborCostsViewModel>? GetMany(int userId, int page)
|
||||
{
|
||||
try
|
||||
{
|
||||
return laborCosts.ReadList(new LaborCostsSearchModel { StaffMemberId = userId });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError(ex, "Ошибка получения списка трудозатрат клиента id = {Id}", userId);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void Create(LaborCostsBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
laborCosts.Create(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError(ex, "Ошибка создания трудозатраты");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void Update(LaborCostsBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
laborCosts.Update(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError(ex, "Ошибка обновления трудозатраты");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void Delete(LaborCostsBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
laborCosts.Delete(new() { Id = model.Id });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError(ex, "Ошибка удаления трудозатраты");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,82 +1,120 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using BeautySalonContracts.BindingModels;
|
||||
using BeautySalonContracts.BusinessLogicContracts;
|
||||
using BeautySalonContracts.SearchModels;
|
||||
using BeautySalonContracts.ViewModels;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace BeatySalonRestApi.Controllers
|
||||
namespace BeautySalonRestApi.Controllers
|
||||
{
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
public class ServiceController : Controller
|
||||
{
|
||||
// GET: ServiceController
|
||||
public ActionResult Index()
|
||||
private readonly ILogger logger;
|
||||
|
||||
private readonly IServiceLogic service;
|
||||
|
||||
public ServiceController(ILogger<ServiceController> logger, IServiceLogic service)
|
||||
{
|
||||
return View();
|
||||
this.logger = logger;
|
||||
this.service = service;
|
||||
}
|
||||
|
||||
// GET: ServiceController/Details/5
|
||||
public ActionResult Details(int id)
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
// GET: ServiceController/Create
|
||||
public ActionResult Create()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
// POST: ServiceController/Create
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public ActionResult Create(IFormCollection collection)
|
||||
[HttpGet]
|
||||
public ServiceViewModel? Get(int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
return RedirectToAction(nameof(Index));
|
||||
return service.ReadElement(new ServiceSearchModel { Id = id });
|
||||
}
|
||||
catch
|
||||
catch (Exception ex)
|
||||
{
|
||||
return View();
|
||||
logger.LogError(ex, "Ошибка получения услуги с id = {Id}", id);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
// GET: ServiceController/Edit/5
|
||||
public ActionResult Edit(int id)
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
// POST: ServiceController/Edit/5
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public ActionResult Edit(int id, IFormCollection collection)
|
||||
[HttpGet]
|
||||
public List<ServiceViewModel>? GetAll()
|
||||
{
|
||||
try
|
||||
{
|
||||
return RedirectToAction(nameof(Index));
|
||||
return service.ReadList(null);
|
||||
}
|
||||
catch
|
||||
catch (Exception ex)
|
||||
{
|
||||
return View();
|
||||
logger.LogError(ex, "Ошибка получения списка услуг");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
// GET: ServiceController/Delete/5
|
||||
public ActionResult Delete(int id)
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
// POST: ServiceController/Delete/5
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public ActionResult Delete(int id, IFormCollection collection)
|
||||
[HttpGet]
|
||||
public List<ServiceViewModel>? GetAllByUser(int userId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return RedirectToAction(nameof(Index));
|
||||
return service.ReadList(new ServiceSearchModel { StaffMemberId = userId });
|
||||
}
|
||||
catch
|
||||
catch (Exception ex)
|
||||
{
|
||||
return View();
|
||||
logger.LogError(ex, "Ошибка получения списка услуг пользователя");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public List<ServiceViewModel>? GetMany(int userId, int page)
|
||||
{
|
||||
try
|
||||
{
|
||||
return service.ReadList(new ServiceSearchModel { StaffMemberId = userId });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError(ex, "Ошибка получения списка услуг клиента id = {Id}", userId);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void Create(ServiceBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
service.Create(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError(ex, "Ошибка создания услуги");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void Update(ServiceBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
service.Update(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError(ex, "Ошибка обновления услуги");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void Delete(ServiceBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
service.Delete(new() { Id = model.Id });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError(ex, "Ошибка удаления услуги");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,83 +1,55 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using BeautySalonContracts.BindingModels;
|
||||
using BeautySalonContracts.BusinessLogicContracts;
|
||||
using BeautySalonContracts.SearchModels;
|
||||
using BeautySalonContracts.ViewModels;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace BeatySalonRestApi.Controllers
|
||||
namespace BeautySalonRestApi.Controllers
|
||||
{
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
public class StaffMemberController : Controller
|
||||
{
|
||||
// GET: StaffMemberController
|
||||
public ActionResult Index()
|
||||
private readonly ILogger _logger;
|
||||
private readonly IOrderLogic _order;
|
||||
private readonly IStaffMemberLogic _logic;
|
||||
public StaffMemberController(IOrderLogic order, IStaffMemberLogic logic, ILogger<StaffMemberController> logger)
|
||||
{
|
||||
return View();
|
||||
_logger = logger;
|
||||
_order = order;
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
// GET: StaffMemberController/Details/5
|
||||
public ActionResult Details(int id)
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
// GET: StaffMemberController/Create
|
||||
public ActionResult Create()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
// POST: StaffMemberController/Create
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public ActionResult Create(IFormCollection collection)
|
||||
[HttpGet]
|
||||
public StaffMemberViewModel? Login(string login, string password)
|
||||
{
|
||||
try
|
||||
{
|
||||
return RedirectToAction(nameof(Index));
|
||||
return _logic.ReadElement(new StaffMemberSearchModel
|
||||
{
|
||||
StaffMemberLogin = login,
|
||||
StaffMemberPassword = password
|
||||
});
|
||||
}
|
||||
catch
|
||||
catch (Exception ex)
|
||||
{
|
||||
return View();
|
||||
_logger.LogError(ex, "Ошибка авторизации сотрудника");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
// GET: StaffMemberController/Edit/5
|
||||
public ActionResult Edit(int id)
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
// POST: StaffMemberController/Edit/5
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public ActionResult Edit(int id, IFormCollection collection)
|
||||
public void Register(StaffMemberBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
return RedirectToAction(nameof(Index));
|
||||
_logic.Create(model);
|
||||
}
|
||||
catch
|
||||
catch (Exception ex)
|
||||
{
|
||||
return View();
|
||||
}
|
||||
}
|
||||
|
||||
// GET: StaffMemberController/Delete/5
|
||||
public ActionResult Delete(int id)
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
// POST: StaffMemberController/Delete/5
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public ActionResult Delete(int id, IFormCollection collection)
|
||||
{
|
||||
try
|
||||
{
|
||||
return RedirectToAction(nameof(Index));
|
||||
}
|
||||
catch
|
||||
{
|
||||
return View();
|
||||
_logger.LogError(ex, "Ошибка регистрации");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user