diff --git a/WMS.WebUI/WMS.WebUI/Controllers/PartnersController.cs b/WMS.WebUI/WMS.WebUI/Controllers/PartnersController.cs new file mode 100644 index 0000000..201e01e --- /dev/null +++ b/WMS.WebUI/WMS.WebUI/Controllers/PartnersController.cs @@ -0,0 +1,135 @@ +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using System.Data; +using System.Reflection.Metadata.Ecma335; +using WMS.WebUI.Helpers; +using WMS.WebUI.Stores; +using WMS.WebUI.Stores.Interfaces; +using WMS.WebUI.ViewModels; +using WMS.WebUI.ViewModels.PartnerViewModels; + +namespace WMS.WebUI.Controllers; + +public class PartnersController : Controller +{ + private readonly IPartnerStore _partnerStore; + + public PartnersController(IPartnerStore partnersStore, + IProductsStore productsStore, + IPartnerStore partnerStore) + { + _partnerStore=partnerStore; + } + + public async Task Index(string? searchString = null, string? partnerType = null) + { + var partners = await _partnerStore.GetPartnersAsync(searchString, partnerType); + + ViewBag.SelectedType = partnerType ?? "All"; + + return View(partners); + } + + public async Task Create() + { + ViewBag.Types = new string[] { "Customer", "Supplier" }; + ViewBag.SelectedType = "Customer"; + + return View(); + } + + [HttpPost] + public async Task Create([FromBody] CreatePartnerViewModel data) + { + if (!ModelState.IsValid) + { + return BadRequest(); + } + + var createdPartner = await _partnerStore.CreateAsync(data); + var result = new + { + redirectToUrl = Url.Action( + "Details", "Partners", + new + { + id = createdPartner.Id, + type = (int)createdPartner.Type + }) + }; + + return Json(result); + } + + + public async Task Details(int id, int type) + { + var partner = await _partnerStore.GetByIdAndTypeAsync(id, (PartnerType)type); + + return View(partner); + } + public async Task Edit(int id, int type) + { + var partner = await _partnerStore.GetByIdAndTypeAsync(id, (PartnerType)type); + + var editPartner = ParseEditPartner(partner); + + return View(editPartner); + } + + [HttpPost] + [ValidateAntiForgeryToken] + public async Task Edit(int id, EditPartnerViewModel partner) + { + try + { + await _partnerStore.UpdateAsync(partner); + + return RedirectToAction(nameof(Details), new { id }); + } + catch + { + return View(partner); + } + } + public async Task Delete(int id, int type) + { + var partner = await _partnerStore.GetByIdAndTypeAsync(id, (PartnerType)type); + + return View(partner); + } + + [HttpPost, ActionName("Delete")] + [ValidateAntiForgeryToken] + public async Task ConfirmDelete(int id, int type) + { + try + { + await _partnerStore.DeleteAsync(id, (PartnerType)type); + + return RedirectToAction(nameof(Index)); + } + catch + { + return View(); + } + } + private EditPartnerViewModel ParseEditPartner(PartnerViewModel partner) + { + string[] nameParts = partner.FullName.Split(new char[] { ' ' }, 2); + + string firstName = nameParts[0]; // First part is the first name + + // If there's more than one part, the rest is considered the last name + string lastName = (nameParts.Length > 1) ? nameParts[1] : ""; + + return new EditPartnerViewModel() + { + Id = partner.Id, + FirstName = firstName, + LastName = lastName, + Balance = partner.Balance, + PhoneNumber = partner.PhoneNumber ?? "", + }; + } +} diff --git a/WMS.WebUI/WMS.WebUI/Controllers/TransactionsController.cs b/WMS.WebUI/WMS.WebUI/Controllers/TransactionsController.cs index 861be7c..0daddb7 100644 --- a/WMS.WebUI/WMS.WebUI/Controllers/TransactionsController.cs +++ b/WMS.WebUI/WMS.WebUI/Controllers/TransactionsController.cs @@ -9,11 +9,15 @@ public class TransactionsController : Controller { private readonly ITransactionsStore _transactionsStore; private readonly IProductsStore _productsStore; + private readonly IPartnerStore _partnerStore; - public TransactionsController(ITransactionsStore transactionsStore, IProductsStore productsStore) + public TransactionsController(ITransactionsStore transactionsStore, + IProductsStore productsStore, + IPartnerStore partnerStore) { _transactionsStore = Validator.NotNull(transactionsStore); _productsStore = Validator.NotNull(productsStore); + _partnerStore=partnerStore; } public async Task Index(string? searchString = null, string? transactionType = null) @@ -24,10 +28,16 @@ public async Task Index(string? searchString = null, string? tran return View(transactions); } + public async Task Details(int id, TransactionType type) + { + var transaction = await _transactionsStore.GetByIdAndTypeAsync(id, type); + + return View(transaction); + } public async Task Create() { - var partnersTask = _transactionsStore.GetPartnersAsync(); + var partnersTask = _partnerStore.GetPartnersAsync(); var productsTask = _productsStore.GetProductsAsync(); await Task.WhenAll(partnersTask, productsTask); @@ -49,7 +59,7 @@ public async Task Create( return BadRequest(); } - var createdTransaction = await _transactionsStore.Create(data); + var createdTransaction = await _transactionsStore.CreateAsync(data); var result = new { redirectToUrl = Url.Action( @@ -63,11 +73,60 @@ public async Task Create( return Json(result); } + public async Task Edit(int id,TransactionType type) + { + var partnersTask = _partnerStore.GetPartnersAsync(); + var productsTask = _productsStore.GetProductsAsync(); + var transaction = _transactionsStore.GetByIdAndTypeAsync(id, type); - public async Task Details(int id, TransactionType type) + await Task.WhenAll(partnersTask, productsTask,transaction); + + ViewBag.Types = new string[] { "Sale", "Supply" }; + ViewBag.SelectedType = "Sale"; + ViewBag.Partners = partnersTask.Result; + ViewBag.Products= productsTask.Result.Data; + + return View(transaction.Result); + } + + [HttpPost] + public async Task Edit( + [FromBody] TransactionView data) + { + if (!ModelState.IsValid) + { + return View(data); + } + await _transactionsStore.UpdateAsync(data); + + var result = new + { + redirectToUrl = Url.Action( + "Details", + new + { + id = data.Id, + type = (int)data.Type + }) + }; + + return Json(result); + } + public async Task Delete(int id, TransactionType type) { var transaction = await _transactionsStore.GetByIdAndTypeAsync(id, type); return View(transaction); } + + [ValidateAntiForgeryToken] + [HttpPost] + [ActionName("Delete")] + public async Task ConfirmDelete(int id, TransactionType type) + { + await _transactionsStore.DeleteAsync(id, type); + + return RedirectToAction(nameof(Index)); + } + } diff --git a/WMS.WebUI/WMS.WebUI/Mappings/CustomerMappings.cs b/WMS.WebUI/WMS.WebUI/Mappings/CustomerMappings.cs new file mode 100644 index 0000000..adbe748 --- /dev/null +++ b/WMS.WebUI/WMS.WebUI/Mappings/CustomerMappings.cs @@ -0,0 +1,19 @@ +using WMS.WebUI.ViewModels.PartnerViewModels; + +namespace WMS.WebUI.Mappings; + +public static class CustomerMappings +{ + public static PartnerViewModel ToPartner(this CustomerViewModel viewModel) + { + return new PartnerViewModel() + { + Id = viewModel.Id, + FullName = viewModel.FullName, + PhoneNumber = viewModel.PhoneNumber, + Balance = viewModel.Balance, + Type = PartnerType.Customer, + }; + } +} + diff --git a/WMS.WebUI/WMS.WebUI/Mappings/SalesMappings.cs b/WMS.WebUI/WMS.WebUI/Mappings/SaleMappings.cs similarity index 92% rename from WMS.WebUI/WMS.WebUI/Mappings/SalesMappings.cs rename to WMS.WebUI/WMS.WebUI/Mappings/SaleMappings.cs index 2fa5f54..011fd2c 100644 --- a/WMS.WebUI/WMS.WebUI/Mappings/SalesMappings.cs +++ b/WMS.WebUI/WMS.WebUI/Mappings/SaleMappings.cs @@ -2,7 +2,7 @@ namespace WMS.WebUI.Mappings; -public static class SalesMappings +public static class SaleMappings { public static TransactionView ToTransaction(this SaleViewModel sale) { diff --git a/WMS.WebUI/WMS.WebUI/Mappings/SupplierMappings.cs b/WMS.WebUI/WMS.WebUI/Mappings/SupplierMappings.cs new file mode 100644 index 0000000..021a03b --- /dev/null +++ b/WMS.WebUI/WMS.WebUI/Mappings/SupplierMappings.cs @@ -0,0 +1,18 @@ +using WMS.WebUI.ViewModels.PartnerViewModels; + +namespace WMS.WebUI.Mappings; + +public static class SupplierMappings +{ + public static PartnerViewModel ToPartner(this SupplierViewModel viewModel) + { + return new PartnerViewModel() + { + Id = viewModel.Id, + FullName = viewModel.FullName, + PhoneNumber = viewModel.PhoneNumber, + Balance = viewModel.Balance, + Type = PartnerType.Supplier, + }; + } +} diff --git a/WMS.WebUI/WMS.WebUI/Program.cs b/WMS.WebUI/WMS.WebUI/Program.cs index f3530fe..e9276fb 100644 --- a/WMS.WebUI/WMS.WebUI/Program.cs +++ b/WMS.WebUI/WMS.WebUI/Program.cs @@ -11,6 +11,7 @@ builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); +builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddSyncfusion(builder.Configuration); diff --git a/WMS.WebUI/WMS.WebUI/Stores/CategoryStore.cs b/WMS.WebUI/WMS.WebUI/Stores/CategoryStore.cs index 36b3424..e1d6de8 100644 --- a/WMS.WebUI/WMS.WebUI/Stores/CategoryStore.cs +++ b/WMS.WebUI/WMS.WebUI/Stores/CategoryStore.cs @@ -10,10 +10,10 @@ public class CategoryStore : ICategoryStore { private readonly HttpClient _client; - public CategoryStore() + public CategoryStore(IConfiguration configuration) { _client = new HttpClient(); - _client.BaseAddress = new Uri("https://localhost:7097/api/"); + _client.BaseAddress = new Uri(configuration["WMSApiUrl"]); } public async Task CreateCategoryAsync(CategoryViewModel category) diff --git a/WMS.WebUI/WMS.WebUI/Stores/DashboardStore.cs b/WMS.WebUI/WMS.WebUI/Stores/DashboardStore.cs index 9a4a232..6165d15 100644 --- a/WMS.WebUI/WMS.WebUI/Stores/DashboardStore.cs +++ b/WMS.WebUI/WMS.WebUI/Stores/DashboardStore.cs @@ -8,10 +8,10 @@ public class DashboardStore : IDashboardStore { private readonly HttpClient _client; - public DashboardStore() + public DashboardStore(IConfiguration configuration) { _client = new HttpClient(); - _client.BaseAddress = new Uri("https://localhost:7097/api/"); + _client.BaseAddress = new Uri(configuration["WMSApiUrl"]); } public async Task Get() diff --git a/WMS.WebUI/WMS.WebUI/Stores/Interfaces/IPartnerStore.cs b/WMS.WebUI/WMS.WebUI/Stores/Interfaces/IPartnerStore.cs new file mode 100644 index 0000000..a97157b --- /dev/null +++ b/WMS.WebUI/WMS.WebUI/Stores/Interfaces/IPartnerStore.cs @@ -0,0 +1,13 @@ +using WMS.WebUI.ViewModels; +using WMS.WebUI.ViewModels.PartnerViewModels; + +namespace WMS.WebUI.Stores.Interfaces; + +public interface IPartnerStore +{ + Task> GetPartnersAsync(string? search="", string? type = ""); + Task GetByIdAndTypeAsync(int id, PartnerType type); + Task CreateAsync(CreatePartnerViewModel partner); + Task UpdateAsync(EditPartnerViewModel partner); + Task DeleteAsync(int id, PartnerType type); +} diff --git a/WMS.WebUI/WMS.WebUI/Stores/Interfaces/ITransactionsStore.cs b/WMS.WebUI/WMS.WebUI/Stores/Interfaces/ITransactionsStore.cs index df55aa6..9bf026f 100644 --- a/WMS.WebUI/WMS.WebUI/Stores/Interfaces/ITransactionsStore.cs +++ b/WMS.WebUI/WMS.WebUI/Stores/Interfaces/ITransactionsStore.cs @@ -1,11 +1,13 @@ using WMS.WebUI.ViewModels; +using WMS.WebUI.ViewModels.PartnerViewModels; namespace WMS.WebUI.Stores.Interfaces; public interface ITransactionsStore { Task> GetTransactionsAsync(string? search, string? type); - Task> GetPartnersAsync(); Task GetByIdAndTypeAsync(int id, TransactionType type); - Task Create(CreateTransactionViewModel transaction); + Task CreateAsync(CreateTransactionViewModel transaction); + Task UpdateAsync(TransactionView transaction); + Task DeleteAsync(int id,TransactionType type); } diff --git a/WMS.WebUI/WMS.WebUI/Stores/PartnerStore.cs b/WMS.WebUI/WMS.WebUI/Stores/PartnerStore.cs new file mode 100644 index 0000000..83d2c9a --- /dev/null +++ b/WMS.WebUI/WMS.WebUI/Stores/PartnerStore.cs @@ -0,0 +1,118 @@ +using Newtonsoft.Json; +using WMS.WebUI.Stores.Interfaces; +using WMS.WebUI.ViewModels; +using WMS.WebUI.ViewModels.PartnerViewModels; +using static System.Runtime.InteropServices.JavaScript.JSType; + +namespace WMS.WebUI.Stores; + +public class PartnerStore : IPartnerStore +{ + private readonly HttpClient _client; + public PartnerStore(IConfiguration configuration) + { + _client = new HttpClient(); + _client.BaseAddress = new Uri(configuration["WMSApiUrl"]); + } + public async Task> GetPartnersAsync(string? search,string? type) + { + var customersTask = _client.GetFromJsonAsync>($"customers?search={search}"); + var suppliersTask = _client.GetFromJsonAsync>($"suppliers?search={search}"); + + await Task.WhenAll(customersTask, suppliersTask); + + customersTask.Result!.ForEach(el => el.Type = PartnerType.Customer); + suppliersTask.Result!.ForEach(el => el.Type = PartnerType.Supplier); + + return [.. customersTask.Result, .. suppliersTask.Result]; + } + public async Task GetByIdAndTypeAsync(int id, PartnerType type) + { + PartnerViewModel partner; + + if (type == PartnerType.Customer) + { + var customer = await _client.GetFromJsonAsync($"customers/{id}"); + partner = new PartnerViewModel + { + Id = id, + FullName = customer.FullName, + Balance = customer.Balance, + PhoneNumber = customer.PhoneNumber, + Type = PartnerType.Customer, + }; + } + else + { + var supplier = await _client.GetFromJsonAsync($"suppliers/{id}"); + partner = new PartnerViewModel + { + Id = id, + FullName = supplier.FullName, + Balance = supplier.Balance, + PhoneNumber = supplier.PhoneNumber, + Type = PartnerType.Supplier, + }; + } + + return partner; + } + public async Task CreateAsync(CreatePartnerViewModel partner) + { + HttpResponseMessage result; + var endpoint = partner.Type == PartnerType.Customer + ? "customers" + : "suppliers"; + var data = new + { + FirstName = partner.FirstName, + LastName = partner.LastName, + Balance = partner.Balance, + PhoneNumber = partner.PhoneNumber, + }; + + result = await _client.PostAsJsonAsync(endpoint, data); + result.EnsureSuccessStatusCode(); + + var json = await result.Content.ReadAsStringAsync(); + var createdPartner = JsonConvert.DeserializeObject(json); + + if (createdPartner is null) + { + throw new InvalidCastException(); + } + + createdPartner.Type = partner.Type; + return createdPartner; + } + public async Task UpdateAsync(EditPartnerViewModel partner) + { + HttpResponseMessage result; + var endpoint = partner.Type == PartnerType.Customer + ? "customers" + : "suppliers"; + + var data = new + { + Id = partner.Id, + FirstName = partner.FirstName, + LastName = partner.LastName, + Balance = partner.Balance, + PhoneNumber = partner.PhoneNumber, + }; + + result = await _client.PutAsJsonAsync(endpoint + $"/{partner.Id}", data); + result.EnsureSuccessStatusCode(); + } + + public async Task DeleteAsync(int id, PartnerType type) + { + HttpResponseMessage result; + var endpoint = type == PartnerType.Customer + ? "customers" + : "suppliers"; + + result = await _client.DeleteAsync(endpoint + $"/{id}"); + result.EnsureSuccessStatusCode(); + } +} diff --git a/WMS.WebUI/WMS.WebUI/Stores/ProductStore.cs b/WMS.WebUI/WMS.WebUI/Stores/ProductStore.cs index 6c04e6b..99f0f7b 100644 --- a/WMS.WebUI/WMS.WebUI/Stores/ProductStore.cs +++ b/WMS.WebUI/WMS.WebUI/Stores/ProductStore.cs @@ -10,10 +10,10 @@ public class ProductStore : IProductsStore { private readonly HttpClient _httpClient; - public ProductStore() + public ProductStore(IConfiguration configuration) { _httpClient = new HttpClient(); - _httpClient.BaseAddress = new Uri("https://localhost:7097/api/"); + _httpClient.BaseAddress = new Uri(configuration["WMSApiUrl"]); } public async Task> GetProductsAsync(string? search = null, int? categoryId = null) diff --git a/WMS.WebUI/WMS.WebUI/Stores/TransactionsStore.cs b/WMS.WebUI/WMS.WebUI/Stores/TransactionsStore.cs index 5e5d73a..11ed9ab 100644 --- a/WMS.WebUI/WMS.WebUI/Stores/TransactionsStore.cs +++ b/WMS.WebUI/WMS.WebUI/Stores/TransactionsStore.cs @@ -2,9 +2,11 @@ using Syncfusion.EJ2.Diagrams; using System.Net.Http.Json; using System.Runtime.CompilerServices; +using System.Transactions; using WMS.WebUI.Mappings; using WMS.WebUI.Stores.Interfaces; using WMS.WebUI.ViewModels; +using WMS.WebUI.ViewModels.PartnerViewModels; namespace WMS.WebUI.Stores; @@ -12,10 +14,10 @@ public class TransactionsStore : ITransactionsStore { private readonly HttpClient _client; - public TransactionsStore() + public TransactionsStore(IConfiguration configuration) { _client = new HttpClient(); - _client.BaseAddress = new Uri("https://localhost:7097/api/"); + _client.BaseAddress = new Uri(configuration["WMSApiUrl"]); } public async Task> GetTransactionsAsync(string? search, string? type) @@ -34,20 +36,6 @@ public async Task> GetTransactionsAsync(string? search, st return transactions; } - - public async Task> GetPartnersAsync() - { - var customersTask = _client.GetFromJsonAsync>("customers"); - var suppliersTask = _client.GetFromJsonAsync>("suppliers"); - - await Task.WhenAll(customersTask, suppliersTask); - - customersTask.Result!.ForEach(el => el.Type = PartnerType.Customer); - suppliersTask.Result!.ForEach(el => el.Type = PartnerType.Supplier); - - return [.. customersTask.Result, .. suppliersTask.Result]; - } - public async Task GetByIdAndTypeAsync(int id, TransactionType type) { TransactionView transaction; @@ -82,7 +70,7 @@ public async Task GetByIdAndTypeAsync(int id, TransactionType t return transaction; } - public async Task Create(CreateTransactionViewModel transaction) + public async Task CreateAsync(CreateTransactionViewModel transaction) { HttpResponseMessage result; var endpoint = transaction.Type == TransactionType.Sale @@ -123,4 +111,46 @@ public async Task Create(CreateTransactionViewModel transaction createdTransaction.Type = transaction.Type; return createdTransaction; } + public async Task UpdateAsync(TransactionView transaction) + { + HttpResponseMessage result; + var endpoint = transaction.Type == TransactionType.Sale + ? "sales" + : "supplies"; + object data; + + if (transaction.Type == TransactionType.Sale) + { + data = new + { + Id = transaction.Id, + CustomerId = transaction.PartnerId, + Date = transaction.Date, + SaleItems = transaction.Items + }; + } + else + { + data = new + { + Id = transaction.Id, + SupplierId = transaction.PartnerId, + Date = transaction.Date, + SupplyItems = transaction.Items + }; + } + + result = await _client.PutAsJsonAsync(endpoint + $"/{transaction.Id}", data); + result.EnsureSuccessStatusCode(); + } + public async Task DeleteAsync(int id,TransactionType type) + { + HttpResponseMessage result; + var endpoint = type == TransactionType.Sale + ? "sales" + : "supplies"; + + result = await _client.DeleteAsync(endpoint + $"/{id}"); + result.EnsureSuccessStatusCode(); + } } \ No newline at end of file diff --git a/WMS.WebUI/WMS.WebUI/ViewModels/PartnerViewModel.cs b/WMS.WebUI/WMS.WebUI/ViewModels/PartnerViewModel.cs deleted file mode 100644 index 8503c58..0000000 --- a/WMS.WebUI/WMS.WebUI/ViewModels/PartnerViewModel.cs +++ /dev/null @@ -1,15 +0,0 @@ -namespace WMS.WebUI.ViewModels; - -public class PartnerViewModel -{ - public int Id { get; set; } - public string FullName { get; set; } - public PartnerType Type { get; set; } - public string PhoneNumber { get; set; } -} - -public enum PartnerType -{ - Customer, - Supplier -} diff --git a/WMS.WebUI/WMS.WebUI/ViewModels/PartnerViewModels/CreatePartnerViewModel.cs b/WMS.WebUI/WMS.WebUI/ViewModels/PartnerViewModels/CreatePartnerViewModel.cs new file mode 100644 index 0000000..a5a53ea --- /dev/null +++ b/WMS.WebUI/WMS.WebUI/ViewModels/PartnerViewModels/CreatePartnerViewModel.cs @@ -0,0 +1,10 @@ +namespace WMS.WebUI.ViewModels.PartnerViewModels; + +public class CreatePartnerViewModel +{ + public string FirstName { get; set; } + public string LastName { get; set; } + public string PhoneNumber { get; set; } + public decimal Balance { get; set; } + public PartnerType Type { get; set; } +} diff --git a/WMS.WebUI/WMS.WebUI/ViewModels/PartnerViewModels/CustomerViewModel.cs b/WMS.WebUI/WMS.WebUI/ViewModels/PartnerViewModels/CustomerViewModel.cs new file mode 100644 index 0000000..99c5cfc --- /dev/null +++ b/WMS.WebUI/WMS.WebUI/ViewModels/PartnerViewModels/CustomerViewModel.cs @@ -0,0 +1,11 @@ +namespace WMS.WebUI.ViewModels.PartnerViewModels; + +public class CustomerViewModel +{ + public int Id { get; set; } + public string FullName { get; init; } + public string PhoneNumber { get; init; } + public string? Address { get; init; } + public decimal Balance { get; init; } + public decimal Discount { get; init; } +} diff --git a/WMS.WebUI/WMS.WebUI/ViewModels/PartnerViewModels/EditPartnerViewModel.cs b/WMS.WebUI/WMS.WebUI/ViewModels/PartnerViewModels/EditPartnerViewModel.cs new file mode 100644 index 0000000..1b549cd --- /dev/null +++ b/WMS.WebUI/WMS.WebUI/ViewModels/PartnerViewModels/EditPartnerViewModel.cs @@ -0,0 +1,11 @@ +namespace WMS.WebUI.ViewModels.PartnerViewModels; + +public class EditPartnerViewModel +{ + public int Id { get; set; } + public string FirstName { get; set; } + public string LastName { get; set; } + public string PhoneNumber { get; set; } + public decimal Balance { get; set; } + public PartnerType Type { get; set; } +} diff --git a/WMS.WebUI/WMS.WebUI/ViewModels/PartnerViewModels/PartnerViewModel.cs b/WMS.WebUI/WMS.WebUI/ViewModels/PartnerViewModels/PartnerViewModel.cs new file mode 100644 index 0000000..7f3bcc6 --- /dev/null +++ b/WMS.WebUI/WMS.WebUI/ViewModels/PartnerViewModels/PartnerViewModel.cs @@ -0,0 +1,22 @@ +using System.ComponentModel; + +namespace WMS.WebUI.ViewModels.PartnerViewModels; + +public class PartnerViewModel +{ + public int Id { get; set; } + + [DisplayName("Full name")] + public string FullName { get; set; } + + [DisplayName("Phone number")] + public string? PhoneNumber { get; set; } + public decimal Balance { get; set; } + public PartnerType Type { get; set; } +} + +public enum PartnerType +{ + Customer, + Supplier +} diff --git a/WMS.WebUI/WMS.WebUI/ViewModels/PartnerViewModels/SupplierViewModel.cs b/WMS.WebUI/WMS.WebUI/ViewModels/PartnerViewModels/SupplierViewModel.cs new file mode 100644 index 0000000..f648a6b --- /dev/null +++ b/WMS.WebUI/WMS.WebUI/ViewModels/PartnerViewModels/SupplierViewModel.cs @@ -0,0 +1,9 @@ +namespace WMS.WebUI.ViewModels.PartnerViewModels; + +public class SupplierViewModel +{ + public int Id { get; init; } + public string FullName { get; set; } + public string PhoneNumber { get; set; } + public decimal Balance { get; set; } +} diff --git a/WMS.WebUI/WMS.WebUI/Views/Partners/Create.cshtml b/WMS.WebUI/WMS.WebUI/Views/Partners/Create.cshtml new file mode 100644 index 0000000..a0f2870 --- /dev/null +++ b/WMS.WebUI/WMS.WebUI/Views/Partners/Create.cshtml @@ -0,0 +1,65 @@ +@model WMS.WebUI.ViewModels.PartnerViewModels.CreatePartnerViewModel; + +
+
+

Create Partner

+
+ + +
+
+ + +
+
+ + +
+ + +
+
+ + diff --git a/WMS.WebUI/WMS.WebUI/Views/Partners/Delete.cshtml b/WMS.WebUI/WMS.WebUI/Views/Partners/Delete.cshtml new file mode 100644 index 0000000..2011cb8 --- /dev/null +++ b/WMS.WebUI/WMS.WebUI/Views/Partners/Delete.cshtml @@ -0,0 +1,50 @@ +@model WMS.WebUI.ViewModels.PartnerViewModels.PartnerViewModel; + +
+

Are you sure

+
+ +
+
+ @Html.DisplayNameFor(model => model.Id) +
+
+ @Html.DisplayFor(model => model.Id) +
+
+ @Html.DisplayNameFor(model => model.FullName) +
+
+ @Html.DisplayFor(model => model.FullName) +
+
+ @Html.DisplayNameFor(model => model.PhoneNumber) +
+
+ @Html.DisplayFor(model => model.PhoneNumber) +
+
+ @Html.DisplayNameFor(model => model.Balance) +
+
+ @Html.DisplayFor(model => model.Balance) +
+
+ @Html.DisplayNameFor(model => model.Type) +
+
+ @Html.DisplayFor(model => model.Type) +
+
+
+ +
+
+ + Back + + +
+
\ No newline at end of file diff --git a/WMS.WebUI/WMS.WebUI/Views/Partners/Details.cshtml b/WMS.WebUI/WMS.WebUI/Views/Partners/Details.cshtml new file mode 100644 index 0000000..62156a7 --- /dev/null +++ b/WMS.WebUI/WMS.WebUI/Views/Partners/Details.cshtml @@ -0,0 +1,52 @@ +@model WMS.WebUI.ViewModels.PartnerViewModels.PartnerViewModel; + +

Partner Details

+
+ +
+
+ @Html.DisplayNameFor(model => model.Id) +
+
+ @Html.DisplayFor(model => model.Id) +
+ +
+ @Html.DisplayNameFor(model => model.FullName) +
+
+ @Html.DisplayFor(model => model.FullName) +
+ +
+ @Html.DisplayNameFor(model => model.PhoneNumber) +
+
+ @Html.DisplayFor(model => model.PhoneNumber) +
+ +
+ @Html.DisplayNameFor(model => model.Balance) +
+
+ @Html.DisplayFor(model => model.Balance) +
+ +
+ @Html.DisplayNameFor(model => model.Type) +
+
+ @Html.DisplayFor(model => model.Type) +
+
+ \ No newline at end of file diff --git a/WMS.WebUI/WMS.WebUI/Views/Partners/Edit.cshtml b/WMS.WebUI/WMS.WebUI/Views/Partners/Edit.cshtml new file mode 100644 index 0000000..180f48d --- /dev/null +++ b/WMS.WebUI/WMS.WebUI/Views/Partners/Edit.cshtml @@ -0,0 +1,29 @@ +@model WMS.WebUI.ViewModels.PartnerViewModels.EditPartnerViewModel + +
+
+

Edit Partner

+ +
+
+ @Html.EJS().TextBox("FirstName").Placeholder("First Name").FloatLabelType(Syncfusion.EJ2.Inputs.FloatLabelType.Auto).Value(Model.FirstName).Render() +
+
+ @Html.EJS().TextBox("LastName").Placeholder("Last Name").FloatLabelType(Syncfusion.EJ2.Inputs.FloatLabelType.Auto).Value(Model.LastName).Render() +
+
+ +
+
+ @Html.EJS().TextBox("PhoneNumber").Placeholder("Phone Number").FloatLabelType(Syncfusion.EJ2.Inputs.FloatLabelType.Auto).Value(Model.PhoneNumber).Render() +
+
+ @Html.EJS().NumericTextBox("Balance").Placeholder("Balance").FloatLabelType(Syncfusion.EJ2.Inputs.FloatLabelType.Auto).Value(Model.Balance).Render() +
+
+ +
+ +
+
+
diff --git a/WMS.WebUI/WMS.WebUI/Views/Partners/Index.cshtml b/WMS.WebUI/WMS.WebUI/Views/Partners/Index.cshtml new file mode 100644 index 0000000..5061680 --- /dev/null +++ b/WMS.WebUI/WMS.WebUI/Views/Partners/Index.cshtml @@ -0,0 +1,67 @@ +@using WMS.WebUI.ViewModels.PartnerViewModels; +@model IEnumerable; + +@{ + var partnerTypes = new string[] { "All", "Customers", "Suppliers" }; +} +
+ +
+
+
+ + +
+ +
+
+ + +
+
+ + +
+
+
+ + +
+
+ + + + + + + + + +
+
+ + + diff --git a/WMS.WebUI/WMS.WebUI/Views/Products/Delete.cshtml b/WMS.WebUI/WMS.WebUI/Views/Products/Delete.cshtml index e1dd794..0995516 100644 --- a/WMS.WebUI/WMS.WebUI/Views/Products/Delete.cshtml +++ b/WMS.WebUI/WMS.WebUI/Views/Products/Delete.cshtml @@ -1,5 +1,68 @@ -@* - For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 -*@ -@{ -} +@model WMS.WebUI.ViewModels.ProductViewModel; + +
+

Are you sure Delete

+
+ +
+
+ @Html.DisplayNameFor(model => model.Id) +
+
+ @Html.DisplayFor(model => model.Id) +
+
+ @Html.DisplayNameFor(model => model.Name) +
+
+ @Html.DisplayFor(model => model.Name) +
+
+ @Html.DisplayNameFor(model => model.Description) +
+
+ @Html.DisplayFor(model => model.Description) +
+
+ @Html.DisplayNameFor(model => model.Category) +
+
+ @Html.DisplayFor(model => model.Category) +
+
+ @Html.DisplayNameFor(model => model.SupplyPrice) +
+
+ @Html.DisplayFor(model => model.SupplyPrice) +
+
+ @Html.DisplayNameFor(model => model.SalePrice) +
+
+ @Html.DisplayFor(model => model.SalePrice) +
+
+ @Html.DisplayNameFor(model => model.QuantityInStock) +
+
+ @Html.DisplayFor(model => model.QuantityInStock) +
+
+ @Html.DisplayNameFor(model => model.LowQuantityAmount) +
+
+ @Html.DisplayFor(model => model.LowQuantityAmount) +
+
+
+ +
+
+ + Back + + +
+
diff --git a/WMS.WebUI/WMS.WebUI/Views/Shared/_Sidebar.cshtml b/WMS.WebUI/WMS.WebUI/Views/Shared/_Sidebar.cshtml index b0c6fc0..513c710 100644 --- a/WMS.WebUI/WMS.WebUI/Views/Shared/_Sidebar.cshtml +++ b/WMS.WebUI/WMS.WebUI/Views/Shared/_Sidebar.cshtml @@ -51,7 +51,7 @@ menuItems.Add(new { text = "Partners", - url = "#", + url = "/partners", iconCss = "fa-solid fa-users" }); diff --git a/WMS.WebUI/WMS.WebUI/Views/Transactions/Delete.cshtml b/WMS.WebUI/WMS.WebUI/Views/Transactions/Delete.cshtml new file mode 100644 index 0000000..e3268e9 --- /dev/null +++ b/WMS.WebUI/WMS.WebUI/Views/Transactions/Delete.cshtml @@ -0,0 +1,65 @@ +@model WMS.WebUI.ViewModels.TransactionView + +
+

Are you sure delete?

+
+ +
+
+ @Html.DisplayNameFor(model => model.Id) +
+
+ @Html.DisplayFor(model => model.Id) +
+
+ @Html.DisplayNameFor(model => model.Date) +
+
+ @Html.DisplayFor(model => model.Date) +
+
+ @Html.DisplayNameFor(model => model.Type) +
+
+ @Html.DisplayFor(model => model.Type) +
+
+ @Html.DisplayNameFor(model => model.Partner) +
+
+ @Html.DisplayFor(model => model.Partner) +
+
+ @Html.DisplayNameFor(model => model.TotalDue) +
+
+ @Html.DisplayFor(model => model.TotalDue) +
+
+ +
+ + + + + + + + + +
+
+ +
+
+ + Back + + +
+
diff --git a/WMS.WebUI/WMS.WebUI/Views/Transactions/Details.cshtml b/WMS.WebUI/WMS.WebUI/Views/Transactions/Details.cshtml index def4434..ae79ace 100644 --- a/WMS.WebUI/WMS.WebUI/Views/Transactions/Details.cshtml +++ b/WMS.WebUI/WMS.WebUI/Views/Transactions/Details.cshtml @@ -1,7 +1,7 @@ @model WMS.WebUI.ViewModels.TransactionView
-

Category details

+

Transaction details


diff --git a/WMS.WebUI/WMS.WebUI/Views/Transactions/Edit.cshtml b/WMS.WebUI/WMS.WebUI/Views/Transactions/Edit.cshtml new file mode 100644 index 0000000..6b626aa --- /dev/null +++ b/WMS.WebUI/WMS.WebUI/Views/Transactions/Edit.cshtml @@ -0,0 +1,147 @@ +@model WMS.WebUI.ViewModels.TransactionView +@using System.Collections.Generic + +
+
+

Create Transaction

+
+ + + + + +
+ + + +
+ +
+
+ + + + +
+
+ + + + + + + + + + +
+
+

0

+
+ + +
+
+ + diff --git a/WMS.WebUI/WMS.WebUI/appsettings.json b/WMS.WebUI/WMS.WebUI/appsettings.json index 10f68b8..07cfc0c 100644 --- a/WMS.WebUI/WMS.WebUI/appsettings.json +++ b/WMS.WebUI/WMS.WebUI/appsettings.json @@ -5,5 +5,6 @@ "Microsoft.AspNetCore": "Warning" } }, - "AllowedHosts": "*" + "AllowedHosts": "*", + "WMSApiUrl": "https://localhost:7097/api/" }