diff --git a/BeautySalonView/ClientWebApp/APIClient.cs b/BeautySalonView/ClientWebApp/APIClient.cs deleted file mode 100644 index bf9b286..0000000 --- a/BeautySalonView/ClientWebApp/APIClient.cs +++ /dev/null @@ -1,68 +0,0 @@ -using BeautySalonContracts.ViewModels; -using Newtonsoft.Json; -using System.Net.Http.Headers; -using System.Text; - -namespace WorkerWebApp -{ - public class APIClient - { - private static readonly HttpClient _client = new(); - - public static ClientViewModel? Client { get; set; } = null; - - public static void Connect(IConfiguration configuration) - { - _client.BaseAddress = new Uri(configuration["IPAddress"]!); - _client.DefaultRequestHeaders.Accept.Clear(); - _client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); - } - - public static T? GetRequest(string requestUrl) - { - var response = _client.GetAsync(requestUrl); - var result = response.Result.Content.ReadAsStringAsync().Result; - Console.WriteLine(requestUrl); - if (response.Result.IsSuccessStatusCode) - { - return JsonConvert.DeserializeObject(result); - } - else - { - throw new Exception(result); - } - } - - public static void PostRequest(string requestUrl, T model) - { - var json = JsonConvert.SerializeObject(model); - var data = new StringContent(json, Encoding.UTF8, "application/json"); - - var response = _client.PostAsync(requestUrl, data); - - var result = response.Result.Content.ReadAsStringAsync().Result; - if (!response.Result.IsSuccessStatusCode) - { - throw new Exception(result); - } - } - - public static O? PostRequestWithResult(string requestUrl, I model) - { - var json = JsonConvert.SerializeObject(model); - var data = new StringContent(json, Encoding.UTF8, "application/json"); - - var response = _client.PostAsync(requestUrl, data); - - var result = response.Result.Content.ReadAsStringAsync().Result; - if (response.Result.IsSuccessStatusCode) - { - return JsonConvert.DeserializeObject(result); - } - else - { - return default; - } - } - } -} diff --git a/BeautySalonView/ClientWebApp/APIWorker.cs b/BeautySalonView/ClientWebApp/APIWorker.cs new file mode 100644 index 0000000..7149cc2 --- /dev/null +++ b/BeautySalonView/ClientWebApp/APIWorker.cs @@ -0,0 +1,49 @@ +using BeautySalonContracts.ViewModels; +using Newtonsoft.Json; +using System.Net.Http.Headers; +using System.Text; + +namespace WorkerWebApp +{ + public class APIWorker + { + private static readonly HttpClient _worker = new(); + + public static WorkerViewModel? Worker { get; set; } = null; + + public static void Connect(IConfiguration configuration) + { + _worker.BaseAddress = new Uri(configuration["IPAddress"]); + _worker.DefaultRequestHeaders.Accept.Clear(); + _worker.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); + } + + public static T? GetRequest(string requestUrl) + { + var response = _worker.GetAsync(requestUrl); + var result = response.Result.Content.ReadAsStringAsync().Result; + if (response.Result.IsSuccessStatusCode) + { + return JsonConvert.DeserializeObject(result); + } + else + { + throw new Exception(result); + } + } + + public static void PostRequest(string requestUrl, T model) + { + var json = JsonConvert.SerializeObject(model); + var data = new StringContent(json, Encoding.UTF8, "application/json"); + + var response = _worker.PostAsync(requestUrl, data); + + var result = response.Result.Content.ReadAsStringAsync().Result; + if (!response.Result.IsSuccessStatusCode) + { + throw new Exception(result); + } + } + } + } \ No newline at end of file diff --git a/BeautySalonView/ClientWebApp/Controllers/EvaluationController.cs b/BeautySalonView/ClientWebApp/Controllers/EvaluationController.cs deleted file mode 100644 index 8ef87d1..0000000 --- a/BeautySalonView/ClientWebApp/Controllers/EvaluationController.cs +++ /dev/null @@ -1,77 +0,0 @@ -using BeautySalonContracts.BindingModels; -using BeautySalonContracts.ViewModels; -using Microsoft.AspNetCore.Mvc; - -namespace WorkerWebApp.Controllers -{ - public class EvaluationController : Controller - { - public IActionResult Create() - { - if (APIClient.Client == null) - { - return Redirect("~/Home/Enter"); - } - ViewBag.Procedure = APIClient.GetRequest>($"api/procedure/getall?userId={APIClient.Client.Id}"); - return View(); - } - - [HttpPost] - public void Create(string pointsProcedure, string pointsCosmetics, int procedureId) - { - if (APIClient.Client == null) - { - throw new Exception("403"); - } - APIClient.PostRequest("api/evaluation/create", new EvaluationBindingModel - { - ClientId = APIClient.Client.Id, - PointsProcedure = double.Parse(pointsProcedure.Replace(".", ",")), - PointsCosmetics = double.Parse(pointsCosmetics.Replace(".", ",")), - ProcedureId = procedureId - }); - Response.Redirect("/Home/Evaluation"); - } - - public IActionResult Update(int id) - { - if (APIClient.Client == null) - { - return Redirect("~/Home/Enter"); - } - ViewBag.Evaluation = APIClient.GetRequest - ($"api/evaluation/get?id={id}"); - ViewBag.Procedure = APIClient.GetRequest>($"api/procedure/getall?userId={APIClient.Client.Id}"); - return View(); - } - - [HttpPost] - public void Update(int id, string pointsProcedure, string pointsCosmetics, int procedureId) - { - if (APIClient.Client == null) - { - throw new Exception("403"); - } - APIClient.PostRequest("api/evaluation/update", new EvaluationBindingModel - { - Id = id, - PointsProcedure = double.Parse(pointsProcedure.Replace(".", ",")), - PointsCosmetics = double.Parse(pointsCosmetics.Replace(".", ",")), - ProcedureId = procedureId - }); - Response.Redirect("/Home/Evaluation"); - } - - [HttpPost] - public void Delete(int id) - { - if (APIClient.Client == null) - { - return; - } - APIClient.PostRequest($"api/evaluation/delete", - new ServiceBindingModel() { Id = id }); - return; - } - } -} diff --git a/BeautySalonView/ClientWebApp/Controllers/HomeController.cs b/BeautySalonView/ClientWebApp/Controllers/HomeController.cs index f98c84d..480fe60 100644 --- a/BeautySalonView/ClientWebApp/Controllers/HomeController.cs +++ b/BeautySalonView/ClientWebApp/Controllers/HomeController.cs @@ -17,171 +17,127 @@ namespace WorkerWebApp.Controllers _logger = logger; } - public IActionResult Enter() + public IActionResult Index() { + //if (APIWorker.Worker == null) + //{ + // return Redirect("~/Home/Enter"); + //} + //return View(APIWorker.GetRequest>($"api/main/getorders?workerId={APIWorker.Worker.Id}")); return View(); } + [HttpGet] + public IActionResult Privacy() + { + if (APIWorker.Worker == null) + { + return Redirect("~/Home/Enter"); + } + return View(APIWorker.Worker); + } + [HttpPost] + + public void Privacy(string login, string password, string fio) + { + if (APIWorker.Worker == null) + { + throw new Exception("Вы как суда попали? Суда вход только авторизованным"); + } + if (string.IsNullOrEmpty(login) || + string.IsNullOrEmpty(password) || string.IsNullOrEmpty(fio)) + { + throw new Exception("Введите логин, пароль и ФИО"); + } + APIWorker.PostRequest("api/worker/updatedata", new WorkerBindingModel + { + Id = APIWorker.Worker.Id, + FullName = fio, + Email = login, + Password = password + }); + APIWorker.Worker.FullName = fio; + APIWorker.Worker.Email = login; + APIWorker.Worker.Password = password; + Response.Redirect("Index"); + } + [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, + NoStore = true)] + public IActionResult Error() + { + return View(new ErrorViewModel + { + RequestId = + Activity.Current?.Id ?? HttpContext.TraceIdentifier + }); + } + [HttpGet] + public IActionResult Enter() //че бомбишь + { + return View(); + } [HttpPost] public void Enter(string login, string password) { - if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password)) + if (string.IsNullOrEmpty(login) || + string.IsNullOrEmpty(password)) { throw new Exception("Введите логин и пароль"); } - APIClient.Client = APIClient.GetRequest($"api/client/login?login={login}&password={password}"); - if (APIClient.Client == null) + APIWorker.Worker = + APIWorker.GetRequest($"api/worker/login?login={login}&password={password}"); + if (APIWorker.Worker == null) { throw new Exception("Неверный логин/пароль"); } Response.Redirect("Index"); } - public IActionResult Procedure(int page) - { - if (APIClient.Client == null) - { - return Redirect("~/Home/Enter"); - } - if (page == 0) - { - page = 1; - } - ViewBag.Procedure = APIClient.GetRequest> - ($"api/procedure/getmany?userId={APIClient.Client.Id}&page={page}"); - ViewBag.Page = page; - ViewBag.NumberOfPages = APIClient.GetRequest - ($"api/procedure/getnumberofpages?userId={APIClient.Client.Id}"); - return View(); - } + [HttpGet] public IActionResult Register() { return View(); } - [HttpPost] - public void Register(string login, string password, string email) + public void Register(string login, string password, string fio) { - if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(email)) + if (string.IsNullOrEmpty(login) || + string.IsNullOrEmpty(password) || string.IsNullOrEmpty(fio)) { throw new Exception("Введите логин, пароль и ФИО"); } - APIClient.PostRequest("api/client/register", new ClientBindingModel + APIWorker.PostRequest("api/worker/register", new + WorkerBindingModel { - ClientEmail = email, - ClientLogin = login, - ClientPassword = password + FullName = fio, + Email = login, + Password = password }); Response.Redirect("Enter"); return; } - - public IActionResult Order(int page) + [HttpGet] + public IActionResult Orders() { - if (APIClient.Client == null) - { - return Redirect("~/Home/Enter"); - } - if (page == 0) - { - page = 1; - } - ViewBag.Order = APIClient.GetRequest> - ($"api/order/getmany?userId={APIClient.Client.Id}&page={page}"); - ViewBag.Page = page; - ViewBag.NumberOfPages = APIClient.GetRequest - ($"api/order/getnumberofpages?userId={APIClient.Client.Id}"); - return View(); + return View(new List()); } - - public IActionResult Evaluation(int page) + [HttpGet] + public IActionResult Procedures() { - if (APIClient.Client == null) - { - return Redirect("~/Home/Enter"); - } - if (page == 0) - { - page = 1; - } - ViewBag.Evaluation = APIClient.GetRequest> - ($"api/evaluation/getmany?userId={APIClient.Client.Id}&page={page}"); - ViewBag.Page = page; - ViewBag.NumberOfPages = APIClient.GetRequest - ($"api/evaluation/getnumberofpages?userId={APIClient.Client.Id}"); - return View(); + return View(new List()); } - - public IActionResult Index() + [HttpGet] + public IActionResult Evaluations() { - if (APIClient.Client == null) - { - return Redirect("~/Home/Enter"); - } - return View(); + return View(new List()); } - - public IActionResult FormationOrder() - { - return View(); - } - - public IActionResult FormingAnEvaluation() - { - return View(); - } - - public IActionResult LinkingProceduresForSelectedOrders() - { - return View(); - } - - public IActionResult ServiceList() - { - if (APIClient.Client == null) - { - return Redirect("~/Home/Enter"); - } - ViewBag.IsAllowed = true; - return View(); - } - - [HttpPost] - public int[]? ServiceList([FromBody] ServiceBindingModel listModel) - { - if (APIClient.Client == null) - { - return Array.Empty(); - } - byte[]? file = APIClient.PostRequestWithResult - ("api/client/ListServices", listModel); - return file!.Select(b => (int)b).ToArray(); - } - - public IActionResult OrderFormationAccordingProcedures() - { - return View(); - } - + [HttpGet] public IActionResult Report() { - return View(); + return View(new List()); //вот тут вопрос } - - [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] - public IActionResult Error() + public IActionResult OrderList() { - return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); - } - - - [HttpGet] - public IActionResult Mails() - { - if (APIClient.Client == null) - { - return Redirect("~/Home/Enter"); - } - return View(APIClient.GetRequest>($"api/client/getmessages?clientId={APIClient.Client.Id}")); + return View(new List()); //тут тоже вопрос } } } \ No newline at end of file diff --git a/BeautySalonView/ClientWebApp/Controllers/OrderController.cs b/BeautySalonView/ClientWebApp/Controllers/OrderController.cs deleted file mode 100644 index 4aa41e8..0000000 --- a/BeautySalonView/ClientWebApp/Controllers/OrderController.cs +++ /dev/null @@ -1,96 +0,0 @@ -using BeautySalonContracts.BindingModels; -using BeautySalonContracts.ViewModels; -using WorkerWebApp; -using Microsoft.AspNetCore.Mvc; - -namespace WorkerWebApp.Controllers -{ - public class OrderController : Controller - { - public IActionResult Create() - { - if (APIClient.Client == null) - { - return Redirect("~/Home/Enter"); - } - return View(); - } - - [HttpPost] - public void Create([FromBody] OrderBindingModel orderModel) - { - if (APIClient.Client == null) - { - throw new Exception("403"); - } - orderModel.ClientId = APIClient.Client.Id; - APIClient.PostRequest("api/order/create", orderModel); - } - - public IActionResult Update(int id) - { - if (APIClient.Client == null) - { - return Redirect("~/Home/Enter"); - } - ViewBag.Id = id; - return View(); - } - - [HttpPost] - public void Update([FromBody] OrderBindingModel orderModel) - { - if (APIClient.Client == null) - { - throw new Exception("403"); - } - orderModel.ClientId = APIClient.Client.Id; - APIClient.PostRequest("api/order/update", orderModel); - } - - [HttpPost] - public void Delete(int id) - { - if (APIClient.Client == null) - { - return; - } - APIClient.PostRequest($"api/order/delete", - new OrderBindingModel() { Id = id }); - return; - } - - [HttpGet] - public List? GetAllServices() - { - if (APIClient.Client == null) - { - throw new Exception("403"); - } - var services = APIClient.GetRequest>($"api/service/getall"); - return services; - } - - public OrderViewModel? Get(int id) - { - if (APIClient.Client == null) - { - return new(); - } - OrderViewModel? order = APIClient - .GetRequest($"api/order/get?id={id}"); - return order; - } - - public List? GetAllByUser() - { - if (APIClient.Client == null) - { - return new(); - } - List? order = APIClient - .GetRequest< List>($"api/order/GetAllByUser?userId={APIClient.Client.Id}"); - return order; - } - } -} diff --git a/BeautySalonView/ClientWebApp/Controllers/ProcedureController.cs b/BeautySalonView/ClientWebApp/Controllers/ProcedureController.cs deleted file mode 100644 index 0442415..0000000 --- a/BeautySalonView/ClientWebApp/Controllers/ProcedureController.cs +++ /dev/null @@ -1,96 +0,0 @@ -using BeautySalonContracts.BindingModels; -using BeautySalonContracts.ViewModels; -using WorkerWebApp; -using Microsoft.AspNetCore.Mvc; - -namespace WorkerWebApp.Controllers -{ - public class ProcedureController : Controller - { - public IActionResult Create() - { - if (APIClient.Client == null) - { - return Redirect("~/Home/Enter"); - } - return View(); - } - - [HttpPost] - public void Create([FromBody] ProcedureBindingModel procedureModel) - { - if (APIClient.Client == null) - { - throw new Exception("403"); - } - procedureModel.ClientId = APIClient.Client.Id; - APIClient.PostRequest("api/procedure/create", procedureModel); - } - - public IActionResult Update(int id) - { - if (APIClient.Client == null) - { - return Redirect("~/Home/Enter"); - } - ViewBag.Id = id; - return View(); - } - - [HttpPost] - public void Update([FromBody] ProcedureBindingModel procedureModel) - { - if (APIClient.Client == null) - { - throw new Exception("403"); - } - procedureModel.ClientId = APIClient.Client.Id; - APIClient.PostRequest("api/procedure/update", procedureModel); - } - - [HttpPost] - public void Delete(int id) - { - if (APIClient.Client == null) - { - return; - } - APIClient.PostRequest($"api/procedure/delete", - new ProcedureBindingModel() { Id = id }); - return; - } - - [HttpGet] - public List? GetAllCosmetics() - { - if (APIClient.Client == null) - { - throw new Exception("403"); - } - var cosmetics = APIClient.GetRequest>($"api/cosmetic/getall"); - return cosmetics; - } - - public ProcedureViewModel? Get(int id) - { - if (APIClient.Client == null) - { - return new(); - } - ProcedureViewModel? procedure = APIClient - .GetRequest($"api/procedure/get?id={id}"); - return procedure; - } - - public List? GetAllByUser() - { - if (APIClient.Client == null) - { - return new(); - } - List? procedures = APIClient.GetRequest> - ($"api/procedure/getallbyuser?userId={APIClient.Client.Id}"); - return procedures; - } - } -} diff --git a/BeautySalonView/ClientWebApp/Views/Home/Enter.cshtml b/BeautySalonView/ClientWebApp/Views/Home/Enter.cshtml index 57576f8..106d3d5 100644 --- a/BeautySalonView/ClientWebApp/Views/Home/Enter.cshtml +++ b/BeautySalonView/ClientWebApp/Views/Home/Enter.cshtml @@ -1,19 +1,21 @@ @{ - ViewData["Title"] = "Вход"; + ViewData["Title"] = "Enter"; } -

Вход в приложение

- +
+

Вход в приложение

+
-
- - -
-
- - -
- +
+
Логин:
+
+
+
+
Пароль:
+
+
+
+
+
+
\ No newline at end of file diff --git a/BeautySalonView/ClientWebApp/Views/Home/Rating.cshtml b/BeautySalonView/ClientWebApp/Views/Home/Evaluation.cshtml similarity index 100% rename from BeautySalonView/ClientWebApp/Views/Home/Rating.cshtml rename to BeautySalonView/ClientWebApp/Views/Home/Evaluation.cshtml diff --git a/BeautySalonView/ClientWebApp/Views/Home/FormationOrder.cshtml b/BeautySalonView/ClientWebApp/Views/Home/FormationOrder.cshtml index ba03400..50b840b 100644 --- a/BeautySalonView/ClientWebApp/Views/Home/FormationOrder.cshtml +++ b/BeautySalonView/ClientWebApp/Views/Home/FormationOrder.cshtml @@ -36,6 +36,7 @@ @foreach (var item in Model) { + } diff --git a/BeautySalonView/StaffMemberWebApp/APIClient.cs b/BeautySalonView/StaffMemberWebApp/APIClient.cs deleted file mode 100644 index 1710fb2..0000000 --- a/BeautySalonView/StaffMemberWebApp/APIClient.cs +++ /dev/null @@ -1,67 +0,0 @@ -using BeautySalonContracts.ViewModels; -using Newtonsoft.Json; -using System.Net.Http.Headers; -using System.Text; - -namespace StorekeeperWebApp -{ - public class APIClient - { - private static readonly HttpClient _client = new(); - - public static StaffMemberViewModel? Client { get; set; } = null; - - public static void Connect(IConfiguration configuration) - { - _client.BaseAddress = new Uri(configuration["IPAddress"]!); - _client.DefaultRequestHeaders.Accept.Clear(); - _client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); - } - - public static T? GetRequest(string requestUrl) - { - var response = _client.GetAsync(requestUrl); - var result = response.Result.Content.ReadAsStringAsync().Result; - if (response.Result.IsSuccessStatusCode) - { - return JsonConvert.DeserializeObject(result); - } - else - { - throw new Exception(result); - } - } - - public static void PostRequest(string requestUrl, T model) - { - var json = JsonConvert.SerializeObject(model); - var data = new StringContent(json, Encoding.UTF8, "application/json"); - - var response = _client.PostAsync(requestUrl, data); - - var result = response.Result.Content.ReadAsStringAsync().Result; - if (!response.Result.IsSuccessStatusCode) - { - throw new Exception(result); - } - } - - public static O? PostRequestWithResult(string requestUrl, I model) - { - var json = JsonConvert.SerializeObject(model); - var data = new StringContent(json, Encoding.UTF8, "application/json"); - - var response = _client.PostAsync(requestUrl, data); - - var result = response.Result.Content.ReadAsStringAsync().Result; - if (response.Result.IsSuccessStatusCode) - { - return JsonConvert.DeserializeObject(result); - } - else - { - return default; - } - } - } -} diff --git a/BeautySalonView/StaffMemberWebApp/APIStorekeeper.cs b/BeautySalonView/StaffMemberWebApp/APIStorekeeper.cs new file mode 100644 index 0000000..0c9066f --- /dev/null +++ b/BeautySalonView/StaffMemberWebApp/APIStorekeeper.cs @@ -0,0 +1,49 @@ +using BeautySalonContracts.ViewModels; +using Newtonsoft.Json; +using System.Net.Http.Headers; +using System.Text; + +namespace StorekeeperWebApp +{ + public class APIStorekeeper + { + private static readonly HttpClient _storekeeper = new(); + + public static StorekeeperViewModel? Storekeeper { get; set; } = null; + + public static void Connect(IConfiguration configuration) + { + _storekeeper.BaseAddress = new Uri(configuration["IPAddress"]); + _storekeeper.DefaultRequestHeaders.Accept.Clear(); + _storekeeper.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); + } + + public static T? GetRequest(string requestUrl) + { + var response = _storekeeper.GetAsync(requestUrl); + var result = response.Result.Content.ReadAsStringAsync().Result; + if (response.Result.IsSuccessStatusCode) + { + return JsonConvert.DeserializeObject(result); + } + else + { + throw new Exception(result); + } + } + + public static void PostRequest(string requestUrl, T model) + { + var json = JsonConvert.SerializeObject(model); + var data = new StringContent(json, Encoding.UTF8, "application/json"); + + var response = _storekeeper.PostAsync(requestUrl, data); + + var result = response.Result.Content.ReadAsStringAsync().Result; + if (!response.Result.IsSuccessStatusCode) + { + throw new Exception(result); + } + } + } +} \ No newline at end of file diff --git a/BeautySalonView/StaffMemberWebApp/Controllers/CosmeticController.cs b/BeautySalonView/StaffMemberWebApp/Controllers/CosmeticController.cs deleted file mode 100644 index 435c856..0000000 --- a/BeautySalonView/StaffMemberWebApp/Controllers/CosmeticController.cs +++ /dev/null @@ -1,102 +0,0 @@ -using BeautySalonContracts.BindingModels; -using BeautySalonContracts.ViewModels; -using Microsoft.AspNetCore.Mvc; - -namespace StorekeeperWebApp.Controllers -{ - public class CosmeticController : Controller - { - public IActionResult Create() - { - if (APIClient.Client == null) - { - return Redirect("~/Home/Enter"); - } - return View(); - } - - [HttpPost] - public void Create(string brand, string cosmeticName, string cosmeticPrice) - { - if (APIClient.Client == null) - { - throw new Exception("403"); - } - APIClient.PostRequest("api/cosmetic/create", new CosmeticBindingModel - { - LaborCostId = APIClient.Client.Id, - Brand = brand, - CosmeticName = cosmeticName, - CosmeticPrice = double.Parse(cosmeticPrice.Replace(".", ",")) - - }); - Response.Redirect("/Home/Cosmetic"); - } - - public IActionResult Update(int id) - { - if (APIClient.Client == null) - { - return Redirect("~/Home/Enter"); - } - ViewBag.Service = APIClient.GetRequest - ($"api/service/get?id={id}"); - ViewBag.Procedure = APIClient.GetRequest - ($"api/procedure/get?id={id}"); - ViewBag.Cosmetic = APIClient.GetRequest> - ($"api/cosmetic/getall?userId={APIClient.Client.Id}"); - return View(); - } - - [HttpPost] - public void Update(int id, string brand, string cosmeticName, string cosmeticPrice) - { - if (APIClient.Client == null) - { - throw new Exception("403"); - } - APIClient.PostRequest("api/cosmetic/update", new CosmeticBindingModel - { - Id = id, - Brand = brand, - CosmeticName = cosmeticName, - CosmeticPrice = double.Parse(cosmeticPrice.Replace(".", ",")) - }); - Response.Redirect("/Home/Wishes"); - } - - [HttpPost] - public void Delete(int id) - { - if (APIClient.Client == null) - { - return; - } - APIClient.PostRequest($"api/cosmetic/delete", - new ServiceBindingModel() { Id = id }); - return; - } - - [HttpGet] - public List? GetAllProcedures() - { - if (APIClient.Client == null) - { - throw new Exception("403"); - } - var procedures = APIClient.GetRequest>($"api/procedure/getall"); - return procedures; - } - [HttpGet] - public List? GetAllByUser() - { - if (APIClient.Client == null) - { - return null; - } - var cosmetics = APIClient.GetRequest> - ($"api/cosmetic/getallbyuser?userId={APIClient.Client.Id}"); - return cosmetics; - } - } -} diff --git a/BeautySalonView/StaffMemberWebApp/Controllers/HomeController.cs b/BeautySalonView/StaffMemberWebApp/Controllers/HomeController.cs index 1008782..fd137a1 100644 --- a/BeautySalonView/StaffMemberWebApp/Controllers/HomeController.cs +++ b/BeautySalonView/StaffMemberWebApp/Controllers/HomeController.cs @@ -10,183 +10,171 @@ namespace SStorekeeperWebApp.Controllers public class HomeController : Controller { private readonly ILogger _logger; - public HomeController(ILogger logger) { _logger = logger; } - + public IActionResult Index() + { + return View(); + if (APIStorekeeper.Storekeeper == null) + { + return Redirect("~/Home/Enter"); + } + return + View(APIStorekeeper.GetRequest>($"api/main/getorders?storekeeperId={APIStorekeeper.Storekeeper.Id}")); + } + [HttpGet] + public IActionResult Privacy() + { + if (APIStorekeeper.Storekeeper == null) + { + return Redirect("~/Home/Enter"); + } + return View(APIStorekeeper.Storekeeper); + } + [HttpPost] + public void Privacy(string login, string password, string fio) + { + if (APIStorekeeper.Storekeeper == null) + { + throw new Exception("Вы как суда попали? Суда вход только авторизованным"); + } + if (string.IsNullOrEmpty(login) || + string.IsNullOrEmpty(password) || string.IsNullOrEmpty(fio)) + { + throw new Exception("Введите логин, пароль и ФИО"); + } + APIStorekeeper.PostRequest("api/storekeeper/updatedata", new StorekeeperBindingModel + { + Id = APIStorekeeper.Storekeeper.Id, + FullName = fio, + Email = login, + Password = password + }); + APIStorekeeper.Storekeeper.FullName = fio; + APIStorekeeper.Storekeeper.Email = login; + APIStorekeeper.Storekeeper.Password = password; + Response.Redirect("Index"); + } + [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, + NoStore = true)] + public IActionResult Error() + { + return View(new ErrorViewModel + { + RequestId = + Activity.Current?.Id ?? HttpContext.TraceIdentifier + }); + } + [HttpGet] public IActionResult Enter() { return View(); } - [HttpPost] public void Enter(string login, string password) { - if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password)) + if (string.IsNullOrEmpty(login) || + string.IsNullOrEmpty(password)) { throw new Exception("Введите логин и пароль"); } - APIClient.Client = APIClient.GetRequest($"api/staffmember/login?login={login}&password={password}"); - if (APIClient.Client == null) + APIStorekeeper.Storekeeper = + APIStorekeeper.GetRequest($"api/storekeeper/login?login={login}&password={password}"); + if (APIStorekeeper.Storekeeper == null) { throw new Exception("Неверный логин/пароль"); } Response.Redirect("Index"); } - - public IActionResult LaborCosts(int page) - { - if (APIClient.Client == null) - { - return Redirect("~/Home/Enter"); - } - if (page == 0) - { - page = 1; - } - ViewBag.LaborCosts = APIClient.GetRequest> - ($"api/laborcosts/getmany?userId={APIClient.Client.Id}&page={page}"); - ViewBag.Page = page; - ViewBag.NumberOfPages = APIClient.GetRequest - ($"api/laborcosts/getnumberofpages?userId={APIClient.Client.Id}"); - return View(); - } - public IActionResult Cosmetic(int page) - { - if (APIClient.Client == null) - { - return Redirect("~/Home/Enter"); - } - if (page == 0) - { - page = 1; - } - ViewBag.Cosmetic = APIClient.GetRequest> - ($"api/cosmetic/getmany?userId={APIClient.Client.Id}&page={page}"); - ViewBag.Page = page; - ViewBag.NumberOfPages = APIClient.GetRequest - ($"api/cosmetic/getnumberofpages?userId={APIClient.Client.Id}"); - return View(); - } - public IActionResult Service(int page) - { - if (APIClient.Client == null) - { - return Redirect("~/Home/Enter"); - } - if (page == 0) - { - page = 1; - } - ViewBag.Service = APIClient.GetRequest> - ($"api/service/getmany?userId={APIClient.Client.Id}&page={page}"); - ViewBag.Page = page; - ViewBag.NumberOfPages = APIClient.GetRequest - ($"api/service/getnumberofpages?userId={APIClient.Client.Id}"); - return View(); - } - - public IActionResult LaborCostsService() - { - return View(); - } - - public IActionResult ListCosmetics() - { - if (APIClient.Client == null) - { - return Redirect("~/Home/Enter"); - } - ViewBag.IsAllowed = true; - return View(); - } - - [HttpPost] - public int[]? ListCosmetics([FromBody] CosmeticBindingModel listModel) - { - if (APIClient.Client == null) - { - return Array.Empty(); - } - byte[]? file = APIClient.PostRequestWithResult - ("api/report/ListCosmetics", listModel); - return file!.Select(b => (int)b).ToArray(); - } - - public IActionResult ProcedureCosmetic() - { - return View(); - } - + [HttpGet] public IActionResult Register() { return View(); } - [HttpPost] - public void Register(string login, string password, string email) + public void Register(string login, string password, string fio) { - if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(email)) + if (string.IsNullOrEmpty(login) || + string.IsNullOrEmpty(password) || string.IsNullOrEmpty(fio)) { throw new Exception("Введите логин, пароль и ФИО"); } - APIClient.PostRequest("api/staffmember/register", new StaffMemberBindingModel + APIStorekeeper.PostRequest("api/storekeeper/register", new + StorekeeperBindingModel { - StaffMemberEmail = email, - StaffMemberLogin = login, - StaffMemberPassword = password + FullName = fio, + Email = login, + Password = password }); Response.Redirect("Enter"); return; } - public IActionResult Index() + //повар + [HttpGet] + public IActionResult Services() { - if (APIClient.Client == null) - { - return Redirect("~/Home/Enter"); - } - return View(); + return View(new List()); } - public IActionResult Report() + [HttpGet] + public IActionResult ServiceCreate() { - return View(); - } - - public IActionResult ServiceCosmetic() - { - return View(); - } - - [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] - public IActionResult Error() - { - return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); + return View(new List()); } [HttpPost] - public List? Report([FromBody] StaffMemberBindingModel reportModel) + public void ServiceCreate(string serviceName, int servicePrice, int experience) { - if (APIClient.Client == null) + /*if (APIStorekeeper.Storekeeper == null) { - return new(); - } - reportModel.StaffMemberFIO = APIClient.Client.Id; - List? list = APIClient.PostRequestWithResult - > - ("api/report/GetServicesReportData", reportModel); - return list; + throw new Exception("Вход только авторизованным"); + }*/ + APIStorekeeper.PostRequest("api/chef/chefcreate", new ServiceBindingModel + { + StorekeeperId = APIStorekeeper.Storekeeper.Id, + ServiceName = serviceName, + ServicePrice = servicePrice, + + }); + Response.Redirect("Chefs"); + } + [HttpGet] + public IActionResult LaborCostUpdate() + { + return View(new List());//тут тоже вопрос } + [HttpGet] - public IActionResult Mails() + public IActionResult Cosmetics() { - if (APIClient.Client == null) - { - return Redirect("~/Home/Enter"); - } - return View(APIClient.GetRequest>($"api/client/getmessages?clientId={APIClient.Client.Id}")); + return View(new List());//уверенности ноль + } + [HttpGet] + public IActionResult CosmeticCreate() + { + return View(new List()); + } + [HttpGet] + public IActionResult CosmeticUpdate() + { + return View(new List()); + } + [HttpGet] + public IActionResult LaborCosts() + { + return View(new List()); + } + [HttpGet] + public IActionResult Report() + { + return View(new List());//вопрос + } + [HttpGet] + public IActionResult List() + { + return View(new List());//вопрос } } } \ No newline at end of file diff --git a/BeautySalonView/StaffMemberWebApp/Controllers/LaborCostsController.cs b/BeautySalonView/StaffMemberWebApp/Controllers/LaborCostsController.cs deleted file mode 100644 index 8363204..0000000 --- a/BeautySalonView/StaffMemberWebApp/Controllers/LaborCostsController.cs +++ /dev/null @@ -1,72 +0,0 @@ -using BeautySalonContracts.BindingModels; -using BeautySalonContracts.ViewModels; -using Microsoft.AspNetCore.Mvc; - -namespace StorekeeperWebApp.Controllers -{ - public class LaborCostsController : Controller - { - public IActionResult Create() - { - if (APIClient.Client == null) - { - return Redirect("~/Home/Enter"); - } - return View(); - } - - [HttpPost] - public void Create(int numberHours, string difficulty) - { - if (APIClient.Client == null) - { - throw new Exception("403"); - } - APIClient.PostRequest("api/laborcosts/create", new LaborCostsBindingModel - { - StaffMemberId = APIClient.Client.Id, - NumberHours = numberHours, - Difficulty = difficulty - }); ; - Response.Redirect("/Home/LaborCosts"); - } - - public IActionResult Update(int id) - { - if (APIClient.Client == null) - { - return Redirect("~/Home/Enter"); - } - ViewBag.LaborCosts = APIClient.GetRequest($"api/laborcosts/get?id={id}"); - return View(); - } - - [HttpPost] - public void Update(int id, int numberHours, string difficulty) - { - if (APIClient.Client == null) - { - throw new Exception("403"); - } - APIClient.PostRequest("api/laborcosts/update", new LaborCostsBindingModel - { - Id = id, - NumberHours = numberHours, - Difficulty = difficulty - }); - Response.Redirect("/Home/LaborCosts"); - } - - [HttpPost] - public void Delete(int id) - { - if (APIClient.Client == null) - { - return; - } - APIClient.PostRequest($"api/laborcosts/delete", - new ServiceBindingModel() { Id = id }); - return; - } - } -} diff --git a/BeautySalonView/StaffMemberWebApp/Controllers/ServiceController.cs b/BeautySalonView/StaffMemberWebApp/Controllers/ServiceController.cs deleted file mode 100644 index ab6e421..0000000 --- a/BeautySalonView/StaffMemberWebApp/Controllers/ServiceController.cs +++ /dev/null @@ -1,108 +0,0 @@ -using BeautySalonContracts.BindingModels; -using BeautySalonContracts.ViewModels; -using Microsoft.AspNetCore.Mvc; - -namespace StorekeeperWebApp.Controllers -{ - public class ServiceController : Controller - { - public IActionResult Create() - { - if (APIClient.Client == null) - { - return Redirect("~/Home/Enter"); - } - ViewBag.LaborCostsList = APIClient.GetRequest>($"api/laborcosts/getall?userId={APIClient.Client.Id}"); - return View(); - } - - [HttpPost] - public void Create(string serviceName, string servicePrice, int laborCostsId) - { - if (APIClient.Client == null) - { - throw new Exception("403"); - } - APIClient.PostRequest("api/service/create", new ServiceBindingModel - { - StaffMemberId = APIClient.Client.Id, - ServiceName = serviceName, - ServicePrice = double.Parse(servicePrice.Replace(".", ",")), - }); - Response.Redirect("/Home/Service"); - } - - public IActionResult Update(int id) - { - if (APIClient.Client == null) - { - return Redirect("~/Home/Enter"); - } - ViewBag.Service = APIClient.GetRequest - ($"api/service/get?id={id}"); - ViewBag.LaborCostsList = APIClient.GetRequest> - ($"api/laborcosts/getall?userId={APIClient.Client.Id}"); - return View(); - } - - [HttpPost] - public void Update(int id, string serviceName, string servicePrice, int laborCostsId) - { - if (APIClient.Client == null) - { - throw new Exception("403"); - } - APIClient.PostRequest("api/service/update", new ServiceBindingModel - { - Id = id, - StaffMemberId = APIClient.Client.Id, - ServiceName = serviceName, - ServicePrice = double.Parse(servicePrice.Replace(".", ",")), - }); - Response.Redirect("/Home/Service"); - } - - [HttpPost] - public void Delete(int id) - { - if (APIClient.Client == null) - { - return; - } - APIClient.PostRequest($"api/service/delete", - new ServiceBindingModel() { Id = id }); - return; - } - - public IActionResult Bind(int id) - { - if (APIClient.Client == null) - { - return Redirect("~/Home/Enter"); - } - ViewBag.ServiceId = id; - return View(); - } - - [HttpPost] - public void Bind([FromBody] ServiceBindingModel serviceModel) - { - if (APIClient.Client == null) - { - throw new Exception("403"); - } - APIClient.PostRequest("api/service/update", serviceModel); - } - - public ServiceViewModel? Get(int id) - { - if (APIClient.Client == null) - { - return new(); - } - ServiceViewModel? service = APIClient - .GetRequest($"api/service/get?id={id}"); - return service; - } - } -}