2023-05-18 23:42:48 +04:00
|
|
|
|
using CaseAccountingContracts.BindingModels;
|
|
|
|
|
using CaseAccountingContracts.ViewModels;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
|
|
|
|
|
namespace CaseAccountingCustomerView.Controllers
|
|
|
|
|
{
|
|
|
|
|
public class Specializations : Controller
|
|
|
|
|
{
|
|
|
|
|
public IActionResult Create()
|
|
|
|
|
{
|
|
|
|
|
if (APIUser.User == null)
|
|
|
|
|
{
|
|
|
|
|
return Redirect("~/Home/Enter");
|
|
|
|
|
}
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void Create([FromBody] SpecializationBindingModel specializationModel)
|
|
|
|
|
{
|
|
|
|
|
if (APIUser.User == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("403");
|
|
|
|
|
}
|
|
|
|
|
specializationModel.UserId = APIUser.User.Id;
|
|
|
|
|
APIUser.PostRequest("api/specialization/create", specializationModel);
|
|
|
|
|
Response.Redirect("/Home/Specializations");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IActionResult Update(int id)
|
|
|
|
|
{
|
|
|
|
|
if (APIUser.User == null)
|
|
|
|
|
{
|
|
|
|
|
return Redirect("~/Home/Enter");
|
|
|
|
|
}
|
|
|
|
|
ViewBag.Specialization = APIUser.GetRequest<SpecializationViewModel>($"api/specialization/get?id={id}");
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void Update([FromBody] SpecializationBindingModel specializationModel)
|
|
|
|
|
{
|
|
|
|
|
if (APIUser.User == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("403");
|
|
|
|
|
}
|
|
|
|
|
specializationModel.UserId = APIUser.User.Id;
|
|
|
|
|
APIUser.PostRequest("api/specialization/update", specializationModel);
|
|
|
|
|
Response.Redirect("/Home/Specializations");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void Delete(int id)
|
|
|
|
|
{
|
|
|
|
|
if (APIUser.User == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("403");
|
|
|
|
|
}
|
|
|
|
|
APIUser.PostRequest($"api/specialization/delete", new SpecializationBindingModel() { Id = id });
|
|
|
|
|
Response.Redirect("/Home/Specializations");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<SpecializationViewModel> GetAllByUser()
|
|
|
|
|
{
|
|
|
|
|
if (APIUser.User == null)
|
|
|
|
|
{
|
|
|
|
|
return new();
|
|
|
|
|
}
|
|
|
|
|
List<SpecializationViewModel>? specializations = APIUser.GetRequest<List<SpecializationViewModel>>($"api/specialization/getallbyuser?userId={APIUser.User.Id}");
|
|
|
|
|
return specializations ?? new();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public SpecializationViewModel? Get(int id)
|
|
|
|
|
{
|
|
|
|
|
if (APIUser.User == null)
|
|
|
|
|
{
|
|
|
|
|
return new();
|
|
|
|
|
}
|
|
|
|
|
SpecializationViewModel? specialization = APIUser.GetRequest<SpecializationViewModel>($"api/specialization/get?id={id}");
|
|
|
|
|
return specialization;
|
|
|
|
|
}
|
2023-05-19 14:53:49 +04:00
|
|
|
|
public IActionResult AddLawyer(int id)
|
|
|
|
|
{
|
|
|
|
|
if (APIUser.User == null)
|
|
|
|
|
{
|
|
|
|
|
return Redirect("~/Home/Enter");
|
|
|
|
|
}
|
|
|
|
|
ViewBag.SpecializationId = id;
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void AddLawyer([FromBody] LawyerBindingModel lawyerModel)
|
|
|
|
|
{
|
|
|
|
|
if (APIUser.User == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("403");
|
|
|
|
|
}
|
|
|
|
|
APIUser.PostRequest("api/lawyer/update", lawyerModel);
|
|
|
|
|
}
|
2023-05-18 23:42:48 +04:00
|
|
|
|
}
|
|
|
|
|
}
|