using Microsoft.AspNetCore.Mvc; using System.Xml.Linq; using TaskTrackerContracts.BindingModels; using TaskTrackerContracts.SearchModels; using TaskTrackerContracts.ViewModels; namespace TaskTrackerClientApp.Controllers { public class EmployeeController : Controller { private readonly ILogger _logger; public EmployeeController(ILogger logger) { _logger = logger; } [HttpGet] public IActionResult CreateEmployee() { return View(); } [HttpPost] public void CreateEmployee(string name, string jobtitle, string email) { if (APIClient.Company == null) { throw new Exception("Вы как суда попали? Суда вход только авторизованным"); } APIClient.PostRequest("api/employee/createemployee", new EmployeeBindingModel { CompanyId = APIClient.Company.Id, Name = name, JobTitle = jobtitle, Email = email }); Response.Redirect("/Home/Employees"); } [HttpPost] public void DeleteEmployee(int id) { if (APIClient.Company == null) { throw new Exception("Вы как суда попали? Суда вход только авторизованным"); } APIClient.PostRequest("api/employee/deleteemployee", new EmployeeSearchModel { CompanyId = APIClient.Company.Id, Name = "f", Id = id }); Response.Redirect("/Home/Employees"); } [HttpGet] public IActionResult UpdateEmployee() { return View(); } [HttpPost] public void UpdateEmployee(int id, string name, string state) { if (APIClient.Company == null) { throw new Exception("Вы как суда попали? Суда вход только авторизованным"); } APIClient.PostRequest("api/employee/updateemployee", new ProjectBindingModel { CompanyId = APIClient.Company.Id, Name = name, State = state, Id = id }); Response.Redirect("/Home/Index"); } [HttpGet] public void ReportEmployee(int id) { if (APIClient.Company == null) { throw new Exception("Вы как суда попали? Суда вход только авторизованным"); } APIClient.PostRequest($"api/task/gettaskemployeelist?id={id}", id); Response.Redirect("/Home/ReportEmployee"); } } }