Compare commits
2 Commits
80322e3819
...
6e1690d28c
Author | SHA1 | Date | |
---|---|---|---|
6e1690d28c | |||
1d879cc660 |
@ -14,6 +14,9 @@ EndProject
|
|||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ComputerShopDatabaseImplement", "ComputerShopDatabaseImplement\ComputerShopDatabaseImplement.csproj", "{CDE4C963-67B5-47A6-A394-901E95EA40F7}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ComputerShopDatabaseImplement", "ComputerShopDatabaseImplement\ComputerShopDatabaseImplement.csproj", "{CDE4C963-67B5-47A6-A394-901E95EA40F7}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ComputerShopImplementerApp", "ComputerShopImplementerApp\ComputerShopImplementerApp.csproj", "{0E13C365-F2CC-4A32-BDD0-52E2DB324734}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ComputerShopImplementerApp", "ComputerShopImplementerApp\ComputerShopImplementerApp.csproj", "{0E13C365-F2CC-4A32-BDD0-52E2DB324734}"
|
||||||
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
|
{BBCF398B-D800-4D8D-99E8-F7ED2CC14A65} = {BBCF398B-D800-4D8D-99E8-F7ED2CC14A65}
|
||||||
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ComputerShopGuarantorApp", "ComputerShopGuarantorApp\ComputerShopGuarantorApp.csproj", "{4E08B0E4-12D4-42BB-A794-995A134A23A8}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ComputerShopGuarantorApp", "ComputerShopGuarantorApp\ComputerShopGuarantorApp.csproj", "{4E08B0E4-12D4-42BB-A794-995A134A23A8}"
|
||||||
EndProject
|
EndProject
|
||||||
|
@ -6,6 +6,10 @@
|
|||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\ComputerShopDataModels\ComputerShopDataModels.csproj" />
|
<ProjectReference Include="..\ComputerShopDataModels\ComputerShopDataModels.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using ComputerShopDataModels.Models;
|
using ComputerShopDataModels.Models;
|
||||||
|
using Newtonsoft.Json;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
@ -29,5 +30,13 @@ namespace ComputerShopContracts.ViewModels
|
|||||||
|
|
||||||
[DisplayName("ФИО клиента")]
|
[DisplayName("ФИО клиента")]
|
||||||
public string ClientFIO { get; set; } = string.Empty;
|
public string ClientFIO { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public RequestViewModel() { }
|
||||||
|
|
||||||
|
[JsonConstructor]
|
||||||
|
public RequestViewModel(Dictionary<int, OrderViewModel> requestOrders)
|
||||||
|
{
|
||||||
|
this.RequestOrders = requestOrders.ToDictionary(x => x.Key, x => x.Value as IOrderModel);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using ComputerShopDataModels.Models;
|
using ComputerShopDataModels.Models;
|
||||||
|
using Newtonsoft.Json;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
@ -25,5 +26,13 @@ namespace ComputerShopContracts.ViewModels
|
|||||||
[DisplayName("Дата поставки")]
|
[DisplayName("Дата поставки")]
|
||||||
public DateTime DateShipment { get; set; } = DateTime.Now;
|
public DateTime DateShipment { get; set; } = DateTime.Now;
|
||||||
|
|
||||||
|
|
||||||
|
public ShipmentViewModel() { }
|
||||||
|
|
||||||
|
[JsonConstructor]
|
||||||
|
public ShipmentViewModel(Dictionary<int, OrderViewModel> shipmentOrders)
|
||||||
|
{
|
||||||
|
this.ShipmentOrders = shipmentOrders.ToDictionary(x => x.Key, x => x.Value as IOrderModel);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ namespace ComputerShopDatabaseImplement.Implements
|
|||||||
public List<OrderViewModel> GetFullList()
|
public List<OrderViewModel> GetFullList()
|
||||||
{
|
{
|
||||||
using var context = new ComputerShopDatabase();
|
using var context = new ComputerShopDatabase();
|
||||||
return context.Orders.Select(x => x.GetViewModel).ToList();
|
return context.Orders.OrderBy(x => x.DateCreate).Select(x => x.GetViewModel).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
//Учитывается id пользователя (везде получение списка только тех записей, что создал сам пользователь)
|
//Учитывается id пользователя (везде получение списка только тех записей, что создал сам пользователь)
|
||||||
@ -33,6 +33,7 @@ namespace ComputerShopDatabaseImplement.Implements
|
|||||||
{
|
{
|
||||||
return context.Orders
|
return context.Orders
|
||||||
.Where(x => (x.UserId == model.UserId) && (x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo))
|
.Where(x => (x.UserId == model.UserId) && (x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo))
|
||||||
|
.OrderBy(x => x.DateCreate)
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
@ -41,12 +42,14 @@ namespace ComputerShopDatabaseImplement.Implements
|
|||||||
{
|
{
|
||||||
return context.Orders
|
return context.Orders
|
||||||
.Where(x => (x.UserId == model.UserId) && (x.Status == model.Status))
|
.Where(x => (x.UserId == model.UserId) && (x.Status == model.Status))
|
||||||
|
.OrderBy(x => x.DateCreate)
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
//возвращение просто всех заказов пользователя (замена GetFullList)
|
//возвращение просто всех заказов пользователя (замена GetFullList)
|
||||||
return context.Orders
|
return context.Orders
|
||||||
.Where(x => x.UserId == model.UserId)
|
.Where(x => x.UserId == model.UserId)
|
||||||
|
.OrderBy(x => x.DateCreate)
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@ namespace ComputerShopDatabaseImplement.Implements
|
|||||||
public class RequestStorage : IRequestStorage
|
public class RequestStorage : IRequestStorage
|
||||||
{
|
{
|
||||||
//id пользователя учитывается в GetFilteredList
|
//id пользователя учитывается в GetFilteredList
|
||||||
|
//!!!ТУТ ДОБАВИЛ .OrderBy(x => x.DateRequest)
|
||||||
public List<RequestViewModel> GetFullList()
|
public List<RequestViewModel> GetFullList()
|
||||||
{
|
{
|
||||||
using var context = new ComputerShopDatabase();
|
using var context = new ComputerShopDatabase();
|
||||||
@ -23,6 +24,7 @@ namespace ComputerShopDatabaseImplement.Implements
|
|||||||
.ThenInclude(x => x.Order)
|
.ThenInclude(x => x.Order)
|
||||||
.Include(x => x.Assembly)
|
.Include(x => x.Assembly)
|
||||||
.ToList()
|
.ToList()
|
||||||
|
.OrderBy(x => x.DateRequest)
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
@ -30,7 +32,7 @@ namespace ComputerShopDatabaseImplement.Implements
|
|||||||
//Учитывается id пользователя (везде получение списка только тех записей, что создал сам пользователь)
|
//Учитывается id пользователя (везде получение списка только тех записей, что создал сам пользователь)
|
||||||
public List<RequestViewModel> GetFilteredList(RequestSearchModel model) {
|
public List<RequestViewModel> GetFilteredList(RequestSearchModel model) {
|
||||||
using var context = new ComputerShopDatabase();
|
using var context = new ComputerShopDatabase();
|
||||||
|
//!!!ТУТ ДОБАВИЛ .OrderBy(x => x.DateRequest)
|
||||||
//сортировка по дате создания заявки
|
//сортировка по дате создания заявки
|
||||||
if (model.DateFrom.HasValue && model.DateTo.HasValue)
|
if (model.DateFrom.HasValue && model.DateTo.HasValue)
|
||||||
{
|
{
|
||||||
@ -39,6 +41,7 @@ namespace ComputerShopDatabaseImplement.Implements
|
|||||||
.Include(x => x.Orders)
|
.Include(x => x.Orders)
|
||||||
.ThenInclude(x => x.Order)
|
.ThenInclude(x => x.Order)
|
||||||
.Include(x => x.Assembly)
|
.Include(x => x.Assembly)
|
||||||
|
.OrderBy(x => x.DateRequest)
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
@ -51,6 +54,7 @@ namespace ComputerShopDatabaseImplement.Implements
|
|||||||
.Include(x => x.Orders)
|
.Include(x => x.Orders)
|
||||||
.ThenInclude(x => x.Order)
|
.ThenInclude(x => x.Order)
|
||||||
.Include(x => x.Assembly)
|
.Include(x => x.Assembly)
|
||||||
|
.OrderBy(x => x.DateRequest)
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
@ -63,6 +67,7 @@ namespace ComputerShopDatabaseImplement.Implements
|
|||||||
.Include(x => x.Orders)
|
.Include(x => x.Orders)
|
||||||
.ThenInclude(x => x.Order)
|
.ThenInclude(x => x.Order)
|
||||||
.Include (x => x.Assembly)
|
.Include (x => x.Assembly)
|
||||||
|
.OrderBy(x => x.DateRequest)
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
@ -73,6 +78,7 @@ namespace ComputerShopDatabaseImplement.Implements
|
|||||||
.Include(x => x.Orders)
|
.Include(x => x.Orders)
|
||||||
.ThenInclude(x => x.Order)
|
.ThenInclude(x => x.Order)
|
||||||
.Include(x => x.Assembly)
|
.Include(x => x.Assembly)
|
||||||
|
.OrderBy(x => x.DateRequest)
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
@ -18,11 +18,12 @@ namespace ComputerShopDatabaseImplement.Implements
|
|||||||
public List<ShipmentViewModel> GetFullList()
|
public List<ShipmentViewModel> GetFullList()
|
||||||
{
|
{
|
||||||
using var context = new ComputerShopDatabase();
|
using var context = new ComputerShopDatabase();
|
||||||
|
//!!!ТУТ ДОБАВИЛ .OrderBy(x => x.DateShipment)
|
||||||
return context.Shipments
|
return context.Shipments
|
||||||
.Include(x => x.Orders)
|
.Include(x => x.Orders)
|
||||||
.ThenInclude(x => x.Order)
|
.ThenInclude(x => x.Order)
|
||||||
.ToList()
|
.ToList()
|
||||||
|
.OrderBy(x => x.DateShipment)
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
@ -31,6 +32,7 @@ namespace ComputerShopDatabaseImplement.Implements
|
|||||||
public List<ShipmentViewModel> GetFilteredList(ShipmentSearchModel model)
|
public List<ShipmentViewModel> GetFilteredList(ShipmentSearchModel model)
|
||||||
{
|
{
|
||||||
using var context = new ComputerShopDatabase();
|
using var context = new ComputerShopDatabase();
|
||||||
|
//!!!ТУТ ДОБАВИЛ .OrderBy(x => x.DateShipment)
|
||||||
//сортировка по дате поставки
|
//сортировка по дате поставки
|
||||||
if (model.DateFrom.HasValue && model.DateTo.HasValue)
|
if (model.DateFrom.HasValue && model.DateTo.HasValue)
|
||||||
{
|
{
|
||||||
@ -38,6 +40,7 @@ namespace ComputerShopDatabaseImplement.Implements
|
|||||||
.Where(x => (x.UserId == model.UserId) && (x.DateShipment >= model.DateFrom && x.DateShipment <= model.DateTo))
|
.Where(x => (x.UserId == model.UserId) && (x.DateShipment >= model.DateFrom && x.DateShipment <= model.DateTo))
|
||||||
.Include(x => x.Orders)
|
.Include(x => x.Orders)
|
||||||
.ThenInclude(x => x.Order)
|
.ThenInclude(x => x.Order)
|
||||||
|
.OrderBy(x => x.DateShipment)
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
@ -48,6 +51,7 @@ namespace ComputerShopDatabaseImplement.Implements
|
|||||||
.Where(x => x.ProviderName == model.ProviderName && x.UserId == model.UserId)
|
.Where(x => x.ProviderName == model.ProviderName && x.UserId == model.UserId)
|
||||||
.Include(x => x.Orders)
|
.Include(x => x.Orders)
|
||||||
.ThenInclude(x => x.Order)
|
.ThenInclude(x => x.Order)
|
||||||
|
.OrderBy(x => x.DateShipment)
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
@ -56,6 +60,7 @@ namespace ComputerShopDatabaseImplement.Implements
|
|||||||
.Where(x => x.UserId == model.UserId)
|
.Where(x => x.UserId == model.UserId)
|
||||||
.Include(x => x.Orders)
|
.Include(x => x.Orders)
|
||||||
.ThenInclude(x => x.Order)
|
.ThenInclude(x => x.Order)
|
||||||
|
.OrderBy(x => x.DateShipment)
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,9 @@ namespace ComputerShopDatabaseImplement.Models
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//DateCreate не обновляю, потому что странно менять дату оформления заказа после его создания
|
//DateCreate не обновляю, потому что странно менять дату оформления заказа после его создания
|
||||||
|
//НА ВСКИЙ ДОБАВИЛ
|
||||||
Status = model.Status;
|
Status = model.Status;
|
||||||
|
DateCreate = model.DateCreate;
|
||||||
}
|
}
|
||||||
|
|
||||||
//отдельный метод изменения стоимости заказа (+ или -) на стоимость сборки внутри заявки (после действий с заявками, кот. привязаны к заказу)
|
//отдельный метод изменения стоимости заказа (+ или -) на стоимость сборки внутри заявки (после действий с заявками, кот. привязаны к заказу)
|
||||||
|
@ -75,6 +75,7 @@ namespace ComputerShopDatabaseImplement.Models
|
|||||||
{
|
{
|
||||||
ClientFIO = model.ClientFIO;
|
ClientFIO = model.ClientFIO;
|
||||||
}
|
}
|
||||||
|
DateRequest = model.DateRequest;
|
||||||
//DateMake не обновляю, потому что странно менять дату оформления заявки после её создания
|
//DateMake не обновляю, потому что странно менять дату оформления заявки после её создания
|
||||||
//Обновление ссылки на сборку (assemblyId) отдельным методом
|
//Обновление ссылки на сборку (assemblyId) отдельным методом
|
||||||
}
|
}
|
||||||
@ -100,9 +101,11 @@ namespace ComputerShopDatabaseImplement.Models
|
|||||||
var requestOrders = context.RequestOrders.Where(x => x.RequestId == model.Id).ToList();
|
var requestOrders = context.RequestOrders.Where(x => x.RequestId == model.Id).ToList();
|
||||||
|
|
||||||
//удаление тех заказов, которых нет в модели (+ изменение суммы у удаляемых заказов)
|
//удаление тех заказов, которых нет в модели (+ изменение суммы у удаляемых заказов)
|
||||||
|
//ИЗМЕНЕНО: удаление всех заказов
|
||||||
if (requestOrders != null && requestOrders.Count > 0)
|
if (requestOrders != null && requestOrders.Count > 0)
|
||||||
{
|
{
|
||||||
var delOrders = requestOrders.Where(x => !model.RequestOrders.ContainsKey(x.OrderId));
|
//var delOrders = requestOrders.Where(x => !model.RequestOrders.ContainsKey(x.OrderId));
|
||||||
|
var delOrders = requestOrders;
|
||||||
foreach (var delOrder in delOrders)
|
foreach (var delOrder in delOrders)
|
||||||
{
|
{
|
||||||
context.RequestOrders.Remove(delOrder);
|
context.RequestOrders.Remove(delOrder);
|
||||||
|
@ -87,9 +87,11 @@ namespace ComputerShopDatabaseImplement.Models
|
|||||||
{
|
{
|
||||||
var shipmentOrders = context.ShipmentOrders.Where(x => x.ShipmentId == model.Id).ToList();
|
var shipmentOrders = context.ShipmentOrders.Where(x => x.ShipmentId == model.Id).ToList();
|
||||||
//удаление тех заказов, которых нет в модели
|
//удаление тех заказов, которых нет в модели
|
||||||
|
//ИСПРАВЛЕНО: удаление всех заказов
|
||||||
if (shipmentOrders != null && shipmentOrders.Count > 0)
|
if (shipmentOrders != null && shipmentOrders.Count > 0)
|
||||||
{
|
{
|
||||||
context.ShipmentOrders.RemoveRange(shipmentOrders.Where(x => !model.ShipmentOrders.ContainsKey(x.OrderId)));
|
//context.ShipmentOrders.RemoveRange(shipmentOrders.Where(x => !model.ShipmentOrders.ContainsKey(x.OrderId)));
|
||||||
|
context.ShipmentOrders.RemoveRange(shipmentOrders);
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
}
|
}
|
||||||
//добавление новых заказов
|
//добавление новых заказов
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@ -18,6 +19,10 @@ namespace ComputerShopDatabaseImplement.Models
|
|||||||
[Required]
|
[Required]
|
||||||
public int OrderId { get; set; }
|
public int OrderId { get; set; }
|
||||||
|
|
||||||
|
//МБ НАДО ТАК:
|
||||||
|
//[ForeignKey("OrderId")]
|
||||||
|
//public virtual Order Order { get; set; }
|
||||||
|
|
||||||
public virtual Shipment Shipment { get; set; } = new();
|
public virtual Shipment Shipment { get; set; } = new();
|
||||||
public virtual Order Order { get; set; } = new();
|
public virtual Order Order { get; set; } = new();
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,16 @@
|
|||||||
using ComputerShopContracts.ViewModels;
|
using ComputerShopContracts.ViewModels;
|
||||||
|
using ComputerShopDatabaseImplement.Models;
|
||||||
|
using ComputerShopDataModels.Models;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using System.Data;
|
||||||
using System.Net.Http.Headers;
|
using System.Net.Http.Headers;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace ComputerShopImplementerApp
|
namespace ComputerShopImplementerApp
|
||||||
{
|
{
|
||||||
public class APIUser
|
public class APIUser
|
||||||
{
|
{
|
||||||
private static readonly HttpClient _user = new();
|
private static readonly HttpClient _user = new HttpClient { Timeout = TimeSpan.FromMinutes(10) };
|
||||||
|
|
||||||
public static UserViewModel? User { get; set; } = null;
|
public static UserViewModel? User { get; set; } = null;
|
||||||
|
|
||||||
@ -24,15 +27,73 @@ namespace ComputerShopImplementerApp
|
|||||||
var result = response.Result.Content.ReadAsStringAsync().Result;
|
var result = response.Result.Content.ReadAsStringAsync().Result;
|
||||||
if (response.Result.IsSuccessStatusCode)
|
if (response.Result.IsSuccessStatusCode)
|
||||||
{
|
{
|
||||||
return JsonConvert.DeserializeObject<T>(result);
|
// var settings = new JsonSerializerSettings
|
||||||
}
|
// {
|
||||||
|
// TypeNameHandling = TypeNameHandling.All
|
||||||
|
//};
|
||||||
|
|
||||||
|
//return JsonConvert.DeserializeObject<T>(result, settings);
|
||||||
|
return JsonConvert.DeserializeObject<T>(result);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new Exception(result);
|
throw new Exception(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void PostRequest<T>(string requestUrl, T model)
|
public static async Task<T?> GetRequestAsync<T>(string requestUrl)
|
||||||
|
{
|
||||||
|
var response = await _user.GetAsync(requestUrl);
|
||||||
|
var result = await response.Content.ReadAsStringAsync();
|
||||||
|
if (response.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
return JsonConvert.DeserializeObject<T>(result);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new Exception(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async Task<T?> GetRequestShipmentAsync<T>(string requestUrl)
|
||||||
|
{
|
||||||
|
var response = await _user.GetAsync(requestUrl);
|
||||||
|
var result = await response.Content.ReadAsStringAsync();
|
||||||
|
if (response.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
var settings = new JsonSerializerSettings
|
||||||
|
{
|
||||||
|
Converters = new List<JsonConverter> { new OrderConverter() }
|
||||||
|
};
|
||||||
|
|
||||||
|
return JsonConvert.DeserializeObject<T>(result, settings);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new Exception(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async Task<T?> GetRequestRequestAsync<T>(string requestUrl)
|
||||||
|
{
|
||||||
|
var response = await _user.GetAsync(requestUrl);
|
||||||
|
var result = await response.Content.ReadAsStringAsync();
|
||||||
|
if (response.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
var settings = new JsonSerializerSettings
|
||||||
|
{
|
||||||
|
Converters = new List<JsonConverter> { new RequestConverter(), new AssemblyConverter() }
|
||||||
|
};
|
||||||
|
|
||||||
|
return JsonConvert.DeserializeObject<T>(result, settings);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new Exception(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void PostRequest<T>(string requestUrl, T model)
|
||||||
{
|
{
|
||||||
var json = JsonConvert.SerializeObject(model);
|
var json = JsonConvert.SerializeObject(model);
|
||||||
var data = new StringContent(json, Encoding.UTF8, "application/json");
|
var data = new StringContent(json, Encoding.UTF8, "application/json");
|
||||||
@ -45,5 +106,76 @@ namespace ComputerShopImplementerApp
|
|||||||
throw new Exception(result);
|
throw new Exception(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
public static async Task PostRequestAsync<T>(string requestUrl, T model)
|
||||||
|
{
|
||||||
|
var json = JsonConvert.SerializeObject(model);
|
||||||
|
var data = new StringContent(json, Encoding.UTF8, "application/json");
|
||||||
|
|
||||||
|
var response = await _user.PostAsync(requestUrl, data);
|
||||||
|
|
||||||
|
var result = await response.Content.ReadAsStringAsync();
|
||||||
|
if (!response.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
throw new Exception(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class OrderConverter : JsonConverter
|
||||||
|
{
|
||||||
|
public override bool CanConvert(Type objectType)
|
||||||
|
{
|
||||||
|
return objectType == typeof(IOrderModel);
|
||||||
|
//return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
|
||||||
|
{
|
||||||
|
return serializer.Deserialize<Order>(reader);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
|
||||||
|
{
|
||||||
|
serializer.Serialize(writer, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class RequestConverter : JsonConverter
|
||||||
|
{
|
||||||
|
public override bool CanConvert(Type objectType)
|
||||||
|
{
|
||||||
|
return objectType == typeof(IRequestModel);
|
||||||
|
//return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
|
||||||
|
{
|
||||||
|
return serializer.Deserialize<Request>(reader);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
|
||||||
|
{
|
||||||
|
serializer.Serialize(writer, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class AssemblyConverter : JsonConverter
|
||||||
|
{
|
||||||
|
public override bool CanConvert(Type objectType)
|
||||||
|
{
|
||||||
|
return objectType == typeof(IAssemblyModel);
|
||||||
|
//return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
|
||||||
|
{
|
||||||
|
return serializer.Deserialize<Assembly>(reader);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
|
||||||
|
{
|
||||||
|
serializer.Serialize(writer, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,11 +7,13 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\ComputerShopBusinessLogic\ComputerShopBusinessLogic.csproj" />
|
||||||
<ProjectReference Include="..\ComputerShopContracts\ComputerShopContracts.csproj" />
|
<ProjectReference Include="..\ComputerShopContracts\ComputerShopContracts.csproj" />
|
||||||
|
<ProjectReference Include="..\ComputerShopDatabaseImplement\ComputerShopDatabaseImplement.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -3,6 +3,9 @@ using ComputerShopContracts.BindingModels;
|
|||||||
using ComputerShopContracts.ViewModels;
|
using ComputerShopContracts.ViewModels;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using ComputerShopDataModels.Enums;
|
||||||
|
using ComputerShopDataModels.Models;
|
||||||
|
using ComputerShopContracts.SearchModels;
|
||||||
|
|
||||||
namespace ComputerShopImplementerApp.Controllers
|
namespace ComputerShopImplementerApp.Controllers
|
||||||
{
|
{
|
||||||
@ -24,6 +27,463 @@ namespace ComputerShopImplementerApp.Controllers
|
|||||||
return View(/*APIUser.GetRequest<List<OrderViewModel>>($"api/main/getorders?userId={APIUser.User.Id}")*/);
|
return View(/*APIUser.GetRequest<List<OrderViewModel>>($"api/main/getorders?userId={APIUser.User.Id}")*/);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ЗАКАЗЫ ЗАКАЗЫ ЗАКАЗЫ ЗАКАЗЫ ЗАКАЗЫ
|
||||||
|
|
||||||
|
//!!!МБ ДОБАВИТЬ [HttpGet]
|
||||||
|
public IActionResult Orders()
|
||||||
|
{
|
||||||
|
if (APIUser.User == null)
|
||||||
|
{
|
||||||
|
return Redirect("~/Home/Enter");
|
||||||
|
}
|
||||||
|
return View(APIUser.GetRequest<List<OrderViewModel>>($"api/order/getorders?userId={APIUser.User.Id}"));
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public OrderViewModel GetOrder(int orderId)
|
||||||
|
{
|
||||||
|
if (APIUser.User == null)
|
||||||
|
{
|
||||||
|
throw new Exception("Необходима авторизация");
|
||||||
|
}
|
||||||
|
var result = APIUser.GetRequest<OrderViewModel>($"api/order/getorder?id={orderId}");
|
||||||
|
if (result == null)
|
||||||
|
{
|
||||||
|
return default;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult CreateOrder()
|
||||||
|
{
|
||||||
|
//!!!ПОТОМ УДАЛИТЬ
|
||||||
|
//ViewBag.OrderStatuses = APIUser.GetRequest<List<String>>("api/order/getorderstatuses");
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public void CreateOrder(OrderStatus status, DateTime date)
|
||||||
|
{
|
||||||
|
if (APIUser.User == null)
|
||||||
|
{
|
||||||
|
throw new Exception("Вход только авторизованным");
|
||||||
|
}
|
||||||
|
//if (count <= 0)
|
||||||
|
//{
|
||||||
|
// throw new Exception("Количество и сумма должны быть больше 0");
|
||||||
|
//}
|
||||||
|
APIUser.PostRequest("api/order/createorder", new OrderBindingModel
|
||||||
|
{
|
||||||
|
UserId = APIUser.User.Id,
|
||||||
|
Status = status,
|
||||||
|
DateCreate = date,
|
||||||
|
Sum = 0
|
||||||
|
});
|
||||||
|
Response.Redirect("Orders");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult UpdateOrder()
|
||||||
|
{
|
||||||
|
if (APIUser.User == null)
|
||||||
|
{
|
||||||
|
return Redirect("~/Home/Enter");
|
||||||
|
}
|
||||||
|
ViewBag.Orders = APIUser.GetRequest<List<OrderViewModel>>($"api/order/getorders?userId={APIUser.User.Id}");
|
||||||
|
//ViewBag.Statuses =
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
|
||||||
|
//МБ ПОСТАВИТЬ int? и передавать order.Value
|
||||||
|
[HttpPost]
|
||||||
|
public void UpdateOrder(int order, OrderStatus status, DateTime date, double sum)
|
||||||
|
{
|
||||||
|
if (APIUser.User == null)
|
||||||
|
{
|
||||||
|
throw new Exception("Вход только авторизованным");
|
||||||
|
}
|
||||||
|
if (order == null)
|
||||||
|
{
|
||||||
|
throw new Exception("Выберите заказ для изменения");
|
||||||
|
}
|
||||||
|
if (status == null)
|
||||||
|
{
|
||||||
|
throw new Exception("Выберите статус для заказа");
|
||||||
|
}
|
||||||
|
//if (count <= 0)
|
||||||
|
//{
|
||||||
|
// throw new Exception("Количество и сумма должны быть больше 0");
|
||||||
|
//}
|
||||||
|
APIUser.PostRequest("api/order/updateorder", new OrderBindingModel
|
||||||
|
{
|
||||||
|
Id = order,
|
||||||
|
UserId = APIUser.User.Id,
|
||||||
|
Status = status,
|
||||||
|
DateCreate = date,
|
||||||
|
Sum = sum
|
||||||
|
});
|
||||||
|
Response.Redirect("Orders");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult DeleteOrder()
|
||||||
|
{
|
||||||
|
if (APIUser.User == null)
|
||||||
|
{
|
||||||
|
return Redirect("~/Home/Enter");
|
||||||
|
}
|
||||||
|
ViewBag.Orders = APIUser.GetRequest<List<OrderViewModel>>($"api/order/getorders?userId={APIUser.User.Id}");
|
||||||
|
//ViewBag.Statuses =
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public void DeleteOrder(int order)
|
||||||
|
{
|
||||||
|
if (APIUser.User == null)
|
||||||
|
{
|
||||||
|
throw new Exception("Вход только авторизованным");
|
||||||
|
}
|
||||||
|
//if (count <= 0)
|
||||||
|
//{
|
||||||
|
// throw new Exception("Количество и сумма должны быть больше 0");
|
||||||
|
//}
|
||||||
|
APIUser.PostRequest("api/order/deleteorder", new OrderBindingModel
|
||||||
|
{
|
||||||
|
Id = order
|
||||||
|
});
|
||||||
|
Response.Redirect("Orders");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// ПАРТИИ ТОВАРОВ ПАРТИИ ТОВАРОВ ПАРТИИ ТОВАРОВ ПАРТИИ ТОВАРОВ ПАРТИИ ТОВАРОВ
|
||||||
|
|
||||||
|
public async Task<IActionResult> Shipments()
|
||||||
|
{
|
||||||
|
if (APIUser.User == null)
|
||||||
|
{
|
||||||
|
return Redirect("~/Home/Enter");
|
||||||
|
}
|
||||||
|
var shipments = await APIUser.GetRequestShipmentAsync<List<ShipmentViewModel>>($"api/shipment/getshipments?userId={APIUser.User.Id}");
|
||||||
|
|
||||||
|
return View(shipments);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public async Task<ShipmentViewModel> GetShipment(int shipmentId)
|
||||||
|
{
|
||||||
|
if (APIUser.User == null)
|
||||||
|
{
|
||||||
|
throw new Exception("Необходима авторизация");
|
||||||
|
}
|
||||||
|
//GetRequestShipmentAsync
|
||||||
|
var result = await APIUser.GetRequestShipmentAsync<ShipmentViewModel>($"api/shipment/getshipment?id={shipmentId}");
|
||||||
|
if (result == null)
|
||||||
|
{
|
||||||
|
return default;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult CreateShipment()
|
||||||
|
{
|
||||||
|
if (APIUser.User == null)
|
||||||
|
{
|
||||||
|
throw new Exception("Вход только авторизованным");
|
||||||
|
}
|
||||||
|
ViewBag.Orders = APIUser.GetRequest<List<OrderViewModel>>($"api/order/getorders?userId={APIUser.User.Id}");
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public void CreateShipment(string providerName, DateTime date, int[] orders)
|
||||||
|
{
|
||||||
|
if (APIUser.User == null)
|
||||||
|
{
|
||||||
|
throw new Exception("Вход только авторизованным");
|
||||||
|
}
|
||||||
|
// Создаем словарь из выбранных заказов
|
||||||
|
var selectedOrders = new Dictionary<int, IOrderModel>();
|
||||||
|
foreach (var orderId in orders)
|
||||||
|
{
|
||||||
|
selectedOrders.Add(orderId, new OrderSearchModel { Id = orderId } as IOrderModel);
|
||||||
|
//var orderModel = APIUser.GetRequest<OrderViewModel>($"api/order/getorder?id={orderId}");
|
||||||
|
//selectedOrders.Add(orderId, orderModel);
|
||||||
|
}
|
||||||
|
|
||||||
|
APIUser.PostRequest("api/shipment/createshipment", new ShipmentBindingModel
|
||||||
|
{
|
||||||
|
UserId = APIUser.User.Id,
|
||||||
|
ProviderName = providerName,
|
||||||
|
DateShipment = date,
|
||||||
|
ShipmentOrders = selectedOrders
|
||||||
|
});
|
||||||
|
Response.Redirect("Shipments");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//!!!МБ СДЕЛАТЬ ПО АНАЛОГИИ С public async Task<IActionResult> Shipments()
|
||||||
|
[HttpGet]
|
||||||
|
public async Task<IActionResult> UpdateShipment()
|
||||||
|
{
|
||||||
|
if (APIUser.User == null)
|
||||||
|
{
|
||||||
|
throw new Exception("Вход только авторизованным");
|
||||||
|
}
|
||||||
|
ViewBag.Shipments = await APIUser.GetRequestShipmentAsync<List<ShipmentViewModel>>($"api/shipment/getshipments?userId={APIUser.User.Id}");
|
||||||
|
ViewBag.Orders = APIUser.GetRequest<List<OrderViewModel>>($"api/order/getorders?userId={APIUser.User.Id}");
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public void UpdateShipment(int shipment, string providerName, DateTime date, int[] orders)
|
||||||
|
{
|
||||||
|
if (APIUser.User == null)
|
||||||
|
{
|
||||||
|
throw new Exception("Вход только авторизованным");
|
||||||
|
}
|
||||||
|
// Создаем словарь из выбранных заказов
|
||||||
|
var selectedOrders = new Dictionary<int, IOrderModel>();
|
||||||
|
foreach (var orderId in orders)
|
||||||
|
{
|
||||||
|
selectedOrders.Add(orderId, new OrderSearchModel { Id = orderId } as IOrderModel);
|
||||||
|
}
|
||||||
|
|
||||||
|
APIUser.PostRequest("api/shipment/updateshipment", new ShipmentBindingModel
|
||||||
|
{
|
||||||
|
Id = shipment,
|
||||||
|
UserId = APIUser.User.Id,
|
||||||
|
ProviderName = providerName,
|
||||||
|
DateShipment = date,
|
||||||
|
ShipmentOrders = selectedOrders
|
||||||
|
});
|
||||||
|
Response.Redirect("Shipments");
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public async Task<IActionResult> DeleteShipment()
|
||||||
|
{
|
||||||
|
if (APIUser.User == null)
|
||||||
|
{
|
||||||
|
throw new Exception("Вход только авторизованным");
|
||||||
|
}
|
||||||
|
ViewBag.Shipments = await APIUser.GetRequestShipmentAsync<List<ShipmentViewModel>>($"api/shipment/getshipments?userId={APIUser.User.Id}");
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//[HttpPost]
|
||||||
|
//public void DeleteShipment(int shipment)
|
||||||
|
//{
|
||||||
|
// if (APIUser.User == null)
|
||||||
|
// {
|
||||||
|
// throw new Exception("Вход только авторизованным");
|
||||||
|
// }
|
||||||
|
// APIUser.PostRequest("api/shipment/deleteshipment", new ShipmentBindingModel
|
||||||
|
// {
|
||||||
|
// Id = shipment
|
||||||
|
// });
|
||||||
|
// Response.Redirect("Shipments");
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<IActionResult> DeleteShipment(int shipment)
|
||||||
|
{
|
||||||
|
if (APIUser.User == null)
|
||||||
|
{
|
||||||
|
throw new Exception("Вход только авторизованным");
|
||||||
|
}
|
||||||
|
await APIUser.PostRequestAsync("api/shipment/deleteshipment", new ShipmentBindingModel
|
||||||
|
{
|
||||||
|
Id = shipment
|
||||||
|
});
|
||||||
|
return RedirectToAction("Shipments");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// ЗАЯВКИ НА СБОРКИ ЗАЯВКИ НА СБОРКИ ЗАЯВКИ НА СБОРКИ ЗАЯВКИ НА СБОРКИ ЗАЯВКИ НА СБОРКИ
|
||||||
|
|
||||||
|
|
||||||
|
//public IActionResult Requests()
|
||||||
|
//{
|
||||||
|
// if (APIUser.User == null)
|
||||||
|
// {
|
||||||
|
// return Redirect("~/Home/Enter");
|
||||||
|
// }
|
||||||
|
// return View(APIUser.GetRequest<List<RequestViewModel>>($"api/request/getrequests?userId={APIUser.User.Id}"));
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
//МБ ТАК Requests
|
||||||
|
public async Task<IActionResult> Requests()
|
||||||
|
{
|
||||||
|
if (APIUser.User == null)
|
||||||
|
{
|
||||||
|
return Redirect("~/Home/Enter");
|
||||||
|
}
|
||||||
|
var requests = await APIUser.GetRequestRequestAsync<List<RequestViewModel>>($"api/request/getrequests?userId={APIUser.User.Id}");
|
||||||
|
//var shipments = await APIUser.GetRequestShipmentAsync<List<ShipmentViewModel>>($"api/shipment/getshipments?userId={APIUser.User.Id}");
|
||||||
|
|
||||||
|
return View(requests);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public async Task<RequestViewModel> GetRequest(int requestId)
|
||||||
|
{
|
||||||
|
if (APIUser.User == null)
|
||||||
|
{
|
||||||
|
throw new Exception("Необходима авторизация");
|
||||||
|
}
|
||||||
|
//GetRequestShipmentAsync
|
||||||
|
var result = await APIUser.GetRequestRequestAsync<RequestViewModel>($"api/request/getrequest?id={requestId}");
|
||||||
|
if (result == null)
|
||||||
|
{
|
||||||
|
return default;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult CreateRequest()
|
||||||
|
{
|
||||||
|
if (APIUser.User == null)
|
||||||
|
{
|
||||||
|
throw new Exception("Вход только авторизованным");
|
||||||
|
}
|
||||||
|
ViewBag.Orders = APIUser.GetRequest<List<OrderViewModel>>($"api/order/getorders?userId={APIUser.User.Id}");
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public void CreateRequest(string clientFIO, DateTime date, int[] orders)
|
||||||
|
{
|
||||||
|
if (APIUser.User == null)
|
||||||
|
{
|
||||||
|
throw new Exception("Вход только авторизованным");
|
||||||
|
}
|
||||||
|
// Создаем словарь из выбранных заказов
|
||||||
|
var selectedOrders = new Dictionary<int, IOrderModel>();
|
||||||
|
foreach (var orderId in orders)
|
||||||
|
{
|
||||||
|
selectedOrders.Add(orderId, new OrderSearchModel { Id = orderId } as IOrderModel);
|
||||||
|
}
|
||||||
|
|
||||||
|
APIUser.PostRequest("api/request/createrequest", new RequestBindingModel
|
||||||
|
{
|
||||||
|
UserId = APIUser.User.Id,
|
||||||
|
ClientFIO = clientFIO,
|
||||||
|
DateRequest = date,
|
||||||
|
RequestOrders = selectedOrders
|
||||||
|
});
|
||||||
|
Response.Redirect("Requests");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public async Task<IActionResult> UpdateRequest()
|
||||||
|
{
|
||||||
|
if (APIUser.User == null)
|
||||||
|
{
|
||||||
|
throw new Exception("Вход только авторизованным");
|
||||||
|
}
|
||||||
|
ViewBag.Requests = await APIUser.GetRequestRequestAsync<List<RequestViewModel>>($"api/request/getrequests?userId={APIUser.User.Id}");
|
||||||
|
ViewBag.Orders = APIUser.GetRequest<List<OrderViewModel>>($"api/order/getorders?userId={APIUser.User.Id}");
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public void UpdateRequest(int request, string clientFIO, DateTime date, int[] orders)
|
||||||
|
{
|
||||||
|
if (APIUser.User == null)
|
||||||
|
{
|
||||||
|
throw new Exception("Вход только авторизованным");
|
||||||
|
}
|
||||||
|
// Создаем словарь из выбранных заказов
|
||||||
|
var selectedOrders = new Dictionary<int, IOrderModel>();
|
||||||
|
foreach (var orderId in orders)
|
||||||
|
{
|
||||||
|
selectedOrders.Add(orderId, new OrderSearchModel { Id = orderId } as IOrderModel);
|
||||||
|
}
|
||||||
|
|
||||||
|
APIUser.PostRequest("api/request/updaterequest", new RequestBindingModel
|
||||||
|
{
|
||||||
|
Id = request,
|
||||||
|
UserId = APIUser.User.Id,
|
||||||
|
ClientFIO = clientFIO,
|
||||||
|
DateRequest = date,
|
||||||
|
RequestOrders = selectedOrders
|
||||||
|
});
|
||||||
|
Response.Redirect("Requests");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public async Task<IActionResult> ConnectRequestAssembly()
|
||||||
|
{
|
||||||
|
if (APIUser.User == null)
|
||||||
|
{
|
||||||
|
throw new Exception("Вход только авторизованным");
|
||||||
|
}
|
||||||
|
ViewBag.Requests = await APIUser.GetRequestRequestAsync<List<RequestViewModel>>($"api/request/getrequests?userId={APIUser.User.Id}");
|
||||||
|
//ViewBag.Orders = APIUser.GetRequest<List<OrderViewModel>>($"api/order/getorders?userId={APIUser.User.Id}");
|
||||||
|
ViewBag.Assemblies = APIUser.GetRequest<List<AssemblyViewModel>>($"api/")
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public async Task<IActionResult> DeleteRequest()
|
||||||
|
{
|
||||||
|
if (APIUser.User == null)
|
||||||
|
{
|
||||||
|
throw new Exception("Вход только авторизованным");
|
||||||
|
}
|
||||||
|
ViewBag.Requests = await APIUser.GetRequestRequestAsync<List<RequestViewModel>>($"api/request/getrequests?userId={APIUser.User.Id}");
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<IActionResult> DeleteRequest(int request)
|
||||||
|
{
|
||||||
|
if (APIUser.User == null)
|
||||||
|
{
|
||||||
|
throw new Exception("Вход только авторизованным");
|
||||||
|
}
|
||||||
|
await APIUser.PostRequestAsync("api/request/deleterequest", new RequestBindingModel
|
||||||
|
{
|
||||||
|
Id = request
|
||||||
|
});
|
||||||
|
return RedirectToAction("Requests");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ОСТАЛЬНОЕ ОСТАЛЬНОЕ ОСТАЛЬНОЕ ОСТАЛЬНОЕ ОСТАЛЬНОЕ ОСТАЛЬНОЕ ОСТАЛЬНОЕ
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public IActionResult Privacy()
|
public IActionResult Privacy()
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,29 @@
|
|||||||
|
using ComputerShopBusinessLogic.BusinessLogics;
|
||||||
|
using ComputerShopContracts.BusinessLogicContracts;
|
||||||
|
using ComputerShopContracts.StorageContracts;
|
||||||
|
using ComputerShopDatabaseImplement.Implements;
|
||||||
|
using ComputerShopDatabaseImplement.Models;
|
||||||
|
using ComputerShopDataModels.Models;
|
||||||
using ComputerShopImplementerApp;
|
using ComputerShopImplementerApp;
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
|
//builder.Services.AddTransient<IUserModel, User>();
|
||||||
|
//builder.Services.AddTransient<IOrder, Order>();
|
||||||
|
//builder.Services.AddTransient<IShipmentModel, Shipment>();
|
||||||
|
//builder.Services.AddTransient<IRequestModel, Request>();
|
||||||
|
|
||||||
|
builder.Services.AddTransient<IUserStorage, UserStorage>();
|
||||||
|
builder.Services.AddTransient<IShipmentStorage, ShipmentStorage>();
|
||||||
|
builder.Services.AddTransient<IRequestStorage, RequestStorage>();
|
||||||
|
builder.Services.AddTransient<IOrderStorage, OrderStorage>();
|
||||||
|
|
||||||
|
|
||||||
|
builder.Services.AddTransient<IUserLogic, UserLogic>();
|
||||||
|
builder.Services.AddTransient<IShipmentLogic, ShipmentLogic>();
|
||||||
|
builder.Services.AddTransient<IRequestLogic, RequestLogic>();
|
||||||
|
builder.Services.AddTransient<IOrderLogic, OrderLogic>();
|
||||||
|
|
||||||
// Add services to the container.
|
// Add services to the container.
|
||||||
builder.Services.AddControllersWithViews();
|
builder.Services.AddControllersWithViews();
|
||||||
|
|
||||||
|
@ -0,0 +1,100 @@
|
|||||||
|
@{
|
||||||
|
ViewData["Title"] = "Connect request with assembly";
|
||||||
|
}
|
||||||
|
<div class="text-center">
|
||||||
|
<h2 class="display-4">Связывание заявки со сборкой</h2>
|
||||||
|
</div>
|
||||||
|
<form method="post">
|
||||||
|
<div class="row">
|
||||||
|
|
||||||
|
<div class="col-md-6">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="mb-3">Выберите завку:</label>
|
||||||
|
<select id="request" name="request" class="form-control">
|
||||||
|
<option selected disabled>Выберите заявку</option>
|
||||||
|
@foreach (var request in ViewBag.Requests)
|
||||||
|
{
|
||||||
|
<option value="@request.Id">@request.DateRequest</option>
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-6">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="mb-3">Выберите сборку:</label>
|
||||||
|
<select id="assembly" name="assembly" class="form-control">
|
||||||
|
<option selected disabled>Выберите сборку</option>
|
||||||
|
@foreach (var assembly in ViewBag.Assemblies)
|
||||||
|
{
|
||||||
|
<option value="@assembly.Id">@assembly.AssemblyName @assembly.Price</option>
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="mb-3">Дата оформления заявки:</label>
|
||||||
|
<input type="datetime-local" id="date" name="date" class="mb-3 form-control" step="1">
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="mb-3">ФИО клиента-заявителя:</label>
|
||||||
|
<input type="text" id="clientFIO" name="clientFIO" class="mb-3 form-control" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-6">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="mb-3">Текущие заказы заявки:</label>
|
||||||
|
@* !!!МБ УБРАТЬ disabled *@
|
||||||
|
<select multiple disabled size="6" id="currentOrders" name="currentOrders" class="form-control">
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-8"></div>
|
||||||
|
<div class="col-4"><input type="submit" value="Изменить" class="btn btn-primary" /></div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
|
||||||
|
<script>
|
||||||
|
$('#request').on('change', function () {
|
||||||
|
check();
|
||||||
|
});
|
||||||
|
function formatDate(date) {
|
||||||
|
var options = { year: 'numeric', month: 'numeric', day: 'numeric', hour: 'numeric', minute: 'numeric', second: 'numeric' };
|
||||||
|
return new Date(date).toLocaleString('ru-RU', options).replace(',', '')/*.replace(/\./g, '').replace(/\s/g, '.')*/;
|
||||||
|
}
|
||||||
|
function check() {
|
||||||
|
var request = $('#request').val();
|
||||||
|
if (request) {
|
||||||
|
$.ajax({
|
||||||
|
method: "GET",
|
||||||
|
url: "/Home/GetRequest",
|
||||||
|
data: { requestId: request },
|
||||||
|
success: function (result) {
|
||||||
|
console.log(result);
|
||||||
|
var localDate = result.dateRequest.toLocaleString();
|
||||||
|
$("#date").val(localDate);
|
||||||
|
$("#clientFIO").val(result.clientFIO);
|
||||||
|
|
||||||
|
$('#currentOrders').empty();
|
||||||
|
// Перебор свойств объекта requestOrders
|
||||||
|
for (var orderId in result.requestOrders) {
|
||||||
|
if (result.requestOrders.hasOwnProperty(orderId)) {
|
||||||
|
var order = result.requestOrders[orderId];
|
||||||
|
var localDate = formatDate(order.dateCreate);
|
||||||
|
$('#currentOrders').append($('<option>', {
|
||||||
|
value: orderId,
|
||||||
|
text: localDate
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
|
</script>
|
61
ComputerShopImplementerApp/Views/Home/CreateOrder.cshtml
Normal file
61
ComputerShopImplementerApp/Views/Home/CreateOrder.cshtml
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
@using ComputerShopDataModels.Enums;
|
||||||
|
@{
|
||||||
|
ViewData["Title"] = "Create order";
|
||||||
|
}
|
||||||
|
<div class="text-center">
|
||||||
|
<h2 class="display-4">Создание заказа</h2>
|
||||||
|
</div>
|
||||||
|
<form method="post">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-4 mb-3">Статус заказа:</div>
|
||||||
|
<div class="col-8 mb-3">
|
||||||
|
<select id="status" name="status" class="form-control">
|
||||||
|
@{
|
||||||
|
foreach (var status in Enum.GetValues(typeof(OrderStatus)))
|
||||||
|
{
|
||||||
|
<option value="@status">@status</option>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
@* !!!ПОТОМ УДАЛИТЬ *@
|
||||||
|
@* <select id="status" name="status" class="form-control" asp-items="@(new SelectList(@ViewBag.OrderStatuses,"Id", "TextileName"))"></select> *@
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-4 mb-3">Дата создания:</div>
|
||||||
|
<div class="col-8 mb-3"><input type="datetime-local" id="date" name="date" step="1"></div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-3">
|
||||||
|
<div class="col-4">Сумма:</div>
|
||||||
|
<div class="col-8"><input type="text" id="sum" name="sum" readonly /></div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-8"></div>
|
||||||
|
<div class="col-4"><input type="submit" value="Создать" class="btn btn-primary" /></div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
@* !!!МБ НАДО БУДЕТ *@
|
||||||
|
@* <script>
|
||||||
|
$('#status').on('change', function () {
|
||||||
|
check();
|
||||||
|
});
|
||||||
|
$('#date').on('change', function () {
|
||||||
|
check();
|
||||||
|
});
|
||||||
|
|
||||||
|
function check() {
|
||||||
|
var status = $('#status').val();
|
||||||
|
var date = $('#date').val();
|
||||||
|
if (status && date) {
|
||||||
|
$.ajax({
|
||||||
|
method: "POST",
|
||||||
|
url: "/Home/Calc",
|
||||||
|
data: { count: count, textile: textile },
|
||||||
|
success: function (result) {
|
||||||
|
$("#sum").val(result);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
|
</script> *@
|
49
ComputerShopImplementerApp/Views/Home/CreateRequest.cshtml
Normal file
49
ComputerShopImplementerApp/Views/Home/CreateRequest.cshtml
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
@{
|
||||||
|
ViewData["Title"] = "Create request";
|
||||||
|
}
|
||||||
|
<div class="text-center">
|
||||||
|
<h2 class="display-4">Создание заявки</h2>
|
||||||
|
</div>
|
||||||
|
<form method="post">
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="mb-3">Дата оформления:</label>
|
||||||
|
<input type="datetime-local" id="date" name="date" class="mb-3 form-control" step="1">
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="mb-3">ФИО клиента-заявителя:</label>
|
||||||
|
<input type="text" id="clientFIO" name="clientFIO" class="mb-3 form-control" />
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="mb-3">Заказы для заявки:</label>
|
||||||
|
<select multiple size="6" id="orders" name="orders" class="form-control">
|
||||||
|
@{
|
||||||
|
foreach (var order in ViewBag.Orders)
|
||||||
|
{
|
||||||
|
<option value="@order.Id">@order.DateCreate</option>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-8"></div>
|
||||||
|
<div class="col-4"><input type="submit" value="Создать" class="btn btn-primary" /></div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
@* !!!МБ НАДО БУДЕТ *@
|
||||||
|
<script>
|
||||||
|
// function toLocalISOString(date) {
|
||||||
|
// const localDate = new Date(date - date.getTimezoneOffset() * 60000); //offset in milliseconds. Credit https://stackoverflow.com/questions/10830357/javascript-toisostring-ignores-timezone-offset
|
||||||
|
|
||||||
|
// // Optionally remove second/millisecond if needed
|
||||||
|
// localDate.setSeconds(null);
|
||||||
|
// localDate.setMilliseconds(null);
|
||||||
|
// return localDate.toISOString().slice(0, -1);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// window.addEventListener("load", () => {
|
||||||
|
// document.getElementById("cal").value = toLocalISOString(new Date());
|
||||||
|
// });
|
||||||
|
</script>
|
||||||
|
|
48
ComputerShopImplementerApp/Views/Home/CreateShipment.cshtml
Normal file
48
ComputerShopImplementerApp/Views/Home/CreateShipment.cshtml
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
@{
|
||||||
|
ViewData["Title"] = "Create shipment";
|
||||||
|
}
|
||||||
|
<div class="text-center">
|
||||||
|
<h2 class="display-4">Создание партии товаров</h2>
|
||||||
|
</div>
|
||||||
|
<form method="post">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="mb-3">Поставщик:</label>
|
||||||
|
<input type="text" id="providerName" name="providerName" class="mb-3 form-control" />
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="mb-3">Дата доставки партии:</label>
|
||||||
|
<input type="datetime-local" id="date" name="date" class="mb-3 form-control" step="1">
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="mb-3">Заказы для партии:</label>
|
||||||
|
<select multiple size="6" id="orders" name="orders" class="form-control">
|
||||||
|
@{
|
||||||
|
foreach (var order in ViewBag.Orders)
|
||||||
|
{
|
||||||
|
<option value="@order.Id">@order.DateCreate</option>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-8"></div>
|
||||||
|
<div class="col-4"><input type="submit" value="Создать" class="btn btn-primary" /></div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
@* !!!МБ НАДО БУДЕТ *@
|
||||||
|
<script>
|
||||||
|
// function toLocalISOString(date) {
|
||||||
|
// const localDate = new Date(date - date.getTimezoneOffset() * 60000); //offset in milliseconds. Credit https://stackoverflow.com/questions/10830357/javascript-toisostring-ignores-timezone-offset
|
||||||
|
|
||||||
|
// // Optionally remove second/millisecond if needed
|
||||||
|
// localDate.setSeconds(null);
|
||||||
|
// localDate.setMilliseconds(null);
|
||||||
|
// return localDate.toISOString().slice(0, -1);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// window.addEventListener("load", () => {
|
||||||
|
// document.getElementById("cal").value = toLocalISOString(new Date());
|
||||||
|
// });
|
||||||
|
</script>
|
||||||
|
|
94
ComputerShopImplementerApp/Views/Home/DeleteOrder.cshtml
Normal file
94
ComputerShopImplementerApp/Views/Home/DeleteOrder.cshtml
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
@using ComputerShopDataModels.Enums;
|
||||||
|
@{
|
||||||
|
ViewData["Title"] = "Update order";
|
||||||
|
}
|
||||||
|
|
||||||
|
<form method="post">
|
||||||
|
<div class="text-center">
|
||||||
|
<h2 class="display-4">Удаление заказа</h2>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="mb-3">Выберите заказ для удаления:</label>
|
||||||
|
<select id="order" name="order" class="mb-3 form-control">
|
||||||
|
<option selected disabled>Выберите заказ</option>
|
||||||
|
@foreach (var order in ViewBag.Orders)
|
||||||
|
{
|
||||||
|
<option value="@order.Id">@order.DateCreate</option>
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
@*<select id="order" name="order" class="form-control" asp-items="@(new SelectList(ViewBag.Orders, "Id", "DateCreate"))"> <option selected disabled>Выберите заказ</option> </select>*@
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="mb-3">Текущий статус заказа:</label>
|
||||||
|
@* <input class="mb-3" type="text" id="currentStatus" name="currentStatus" readonly /> *@
|
||||||
|
<span id="currentStatus" style="font-weight: bold;"></span>
|
||||||
|
</div>
|
||||||
|
@* <div class="row">
|
||||||
|
<div class="col-4 mb-3">Статус заказа:</div>
|
||||||
|
<div class="col-8 mb-3">
|
||||||
|
<select id="status" name="status" class="form-control">
|
||||||
|
@{
|
||||||
|
foreach (var status in Enum.GetValues(typeof(OrderStatus)))
|
||||||
|
{
|
||||||
|
<option value="@status">@status</option>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div> *@
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="mb-3">Дата создания:</label>
|
||||||
|
@* <div class="col-8 mb-3"> *@<input type="datetime-local" id="date" name="date" class="mb-3 form-control">@* </div> *@
|
||||||
|
</div>
|
||||||
|
@* <div class="row">
|
||||||
|
<div class="col-4 mb-3">Дата создания:</div>
|
||||||
|
<div class="col-8 mb-3"><input type="datetime-local" id="date" name="date"></div>
|
||||||
|
</div> *@
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Сумма:</label>
|
||||||
|
@* <div class="col-8"><input type="text" id="sum" name="sum" readonly /></div> *@
|
||||||
|
<input type="number" id="sum" name="sum" readonly />
|
||||||
|
</div>
|
||||||
|
@* <div class="row mb-3">
|
||||||
|
<div class="col-4">Сумма:</div>
|
||||||
|
<div class="col-8"><input type="text" id="sum" name="sum" readonly /></div>
|
||||||
|
</div> *@
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-8"></div>
|
||||||
|
<div class="col-4"><input type="submit" value="Удалить" class="btn btn-primary" /></div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
|
||||||
|
<script>
|
||||||
|
$('#order').on('change', function () {
|
||||||
|
check();
|
||||||
|
});
|
||||||
|
var orderStatusNames = [
|
||||||
|
"Неизвестен",
|
||||||
|
"Принят",
|
||||||
|
"Выполняется",
|
||||||
|
"Готов",
|
||||||
|
"Выдан"
|
||||||
|
];
|
||||||
|
function check() {
|
||||||
|
var order = $('#order').val();
|
||||||
|
if (order) {
|
||||||
|
$.ajax({
|
||||||
|
method: "GET",
|
||||||
|
url: "/Home/GetOrder",
|
||||||
|
data: { orderId: order },
|
||||||
|
success: function (result) {
|
||||||
|
console.log(result);
|
||||||
|
var localDate = result.dateCreate.toLocaleString();
|
||||||
|
$("#date").val(localDate);
|
||||||
|
//!!!ТУТ КАК-ТО ВЫВЕСТИ СТАТУС
|
||||||
|
var orderStatusName = orderStatusNames[result.status + 1];
|
||||||
|
$("#currentStatus").text(orderStatusName);
|
||||||
|
$("#sum").val(result.sum);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
81
ComputerShopImplementerApp/Views/Home/DeleteRequest.cshtml
Normal file
81
ComputerShopImplementerApp/Views/Home/DeleteRequest.cshtml
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
@{
|
||||||
|
ViewData["Title"] = "Delete request";
|
||||||
|
}
|
||||||
|
<div class="text-center">
|
||||||
|
<h2 class="display-4">Удаление заявки</h2>
|
||||||
|
</div>
|
||||||
|
<form method="post">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="mb-3">Выберите завку для удаления:</label>
|
||||||
|
<select id="request" name="request" class="form-control">
|
||||||
|
<option selected disabled>Выберите заявку</option>
|
||||||
|
@foreach (var request in ViewBag.Requests)
|
||||||
|
{
|
||||||
|
<option value="@request.Id">@request.DateRequest</option>
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="mb-3">Дата оформления:</label>
|
||||||
|
<input type="datetime-local" id="date" name="date" class="mb-3 form-control" step="1">
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="mb-3">ФИО клиента-заявителя:</label>
|
||||||
|
<input type="text" id="clientFIO" name="clientFIO" class="mb-3 form-control" />
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-6">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="mb-3">Текущие заказы заявки:</label>
|
||||||
|
<select multiple disabled size="6" id="currentOrders" name="currentOrders" class="form-control">
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-8"></div>
|
||||||
|
<div class="col-4"><input type="submit" value="Удалить" class="btn btn-primary" /></div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
|
||||||
|
<script>
|
||||||
|
$('#request').on('change', function () {
|
||||||
|
check();
|
||||||
|
});
|
||||||
|
function formatDate(date) {
|
||||||
|
var options = { year: 'numeric', month: 'numeric', day: 'numeric', hour: 'numeric', minute: 'numeric', second: 'numeric' };
|
||||||
|
return new Date(date).toLocaleString('ru-RU', options).replace(',', '')/*.replace(/\./g, '').replace(/\s/g, '.')*/;
|
||||||
|
}
|
||||||
|
function check() {
|
||||||
|
var request = $('#request').val();
|
||||||
|
if (request) {
|
||||||
|
$.ajax({
|
||||||
|
method: "GET",
|
||||||
|
url: "/Home/GetRequest",
|
||||||
|
data: { requestId: request },
|
||||||
|
success: function (result) {
|
||||||
|
console.log(result);
|
||||||
|
var localDate = result.dateRequest.toLocaleString();
|
||||||
|
$("#date").val(localDate);
|
||||||
|
$("#clientFIO").val(result.clientFIO);
|
||||||
|
|
||||||
|
$('#currentOrders').empty();
|
||||||
|
// Перебор свойств объекта requestOrders
|
||||||
|
for (var orderId in result.requestOrders) {
|
||||||
|
if (result.requestOrders.hasOwnProperty(orderId)) {
|
||||||
|
var order = result.requestOrders[orderId];
|
||||||
|
var localDate = formatDate(order.dateCreate);
|
||||||
|
$('#currentOrders').append($('<option>', {
|
||||||
|
value: orderId,
|
||||||
|
text: localDate
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
80
ComputerShopImplementerApp/Views/Home/DeleteShipment.cshtml
Normal file
80
ComputerShopImplementerApp/Views/Home/DeleteShipment.cshtml
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
@{
|
||||||
|
ViewData["Title"] = "Delete shipment";
|
||||||
|
}
|
||||||
|
<div class="text-center">
|
||||||
|
<h2 class="display-4">Удаление партии товаров</h2>
|
||||||
|
</div>
|
||||||
|
<form method="post">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="mb-3">Партия товаров для удаления:</label>
|
||||||
|
<select id="shipment" name="shipment" class="form-control">
|
||||||
|
<option selected disabled>Выберите партию товаров</option>
|
||||||
|
@foreach (var shipment in ViewBag.Shipments)
|
||||||
|
{
|
||||||
|
<option value="@shipment.Id">@shipment.DateShipment</option>
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="mb-3">Поставщик:</label>
|
||||||
|
<input disabled type="text" id="providerName" name="providerName" class="mb-3 form-control" />
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="mb-3">Дата доставки партии:</label>
|
||||||
|
<input disabled type="datetime-local" id="date" name="date" class="mb-3 form-control" step="1">
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-6">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="mb-3">Текущие заказы партии:</label>
|
||||||
|
<select multiple disabled size="6" id="currentOrders" name="currentOrders" class="form-control">
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-8"></div>
|
||||||
|
<div class="col-4"><input type="submit" value="Удалить" class="btn btn-primary" /></div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
|
||||||
|
<script>
|
||||||
|
$('#shipment').on('change', function () {
|
||||||
|
check();
|
||||||
|
});
|
||||||
|
function formatDate(date) {
|
||||||
|
var options = { year: 'numeric', month: 'numeric', day: 'numeric', hour: 'numeric', minute: 'numeric', second: 'numeric' };
|
||||||
|
return new Date(date).toLocaleString('ru-RU', options).replace(',', '')/*.replace(/\./g, '').replace(/\s/g, '.')*/;
|
||||||
|
}
|
||||||
|
function check() {
|
||||||
|
var shipment = $('#shipment').val();
|
||||||
|
if (shipment) {
|
||||||
|
$.ajax({
|
||||||
|
method: "GET",
|
||||||
|
url: "/Home/GetShipment",
|
||||||
|
data: { shipmentId: shipment },
|
||||||
|
success: function (result) {
|
||||||
|
console.log(result);
|
||||||
|
var localDate = result.dateShipment.toLocaleString();
|
||||||
|
$("#date").val(localDate);
|
||||||
|
$("#providerName").val(result.providerName);
|
||||||
|
|
||||||
|
$('#currentOrders').empty();
|
||||||
|
// Перебор свойств объекта shipmentOrders
|
||||||
|
for (var orderId in result.shipmentOrders) {
|
||||||
|
if (result.shipmentOrders.hasOwnProperty(orderId)) {
|
||||||
|
var order = result.shipmentOrders[orderId];
|
||||||
|
var localDate = formatDate(order.dateCreate);
|
||||||
|
$('#currentOrders').append($('<option>', {
|
||||||
|
value: orderId,
|
||||||
|
text: localDate
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
|
</script>
|
66
ComputerShopImplementerApp/Views/Home/Orders.cshtml
Normal file
66
ComputerShopImplementerApp/Views/Home/Orders.cshtml
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
@using ComputerShopContracts.ViewModels
|
||||||
|
|
||||||
|
@model List<OrderViewModel>
|
||||||
|
@* !!!ТУТ СКОРЕЕ ВСЕГО НАДО ПОМЕНЯТЬ *@
|
||||||
|
@{
|
||||||
|
ViewData["Title"] = "Orders";
|
||||||
|
}
|
||||||
|
|
||||||
|
<div class="text-center">
|
||||||
|
<h1 class="display-4">Заказы</h1>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="text-center">
|
||||||
|
@{
|
||||||
|
if (Model == null)
|
||||||
|
{
|
||||||
|
<h3 class="display-4">Авторизируйтесь</h3>
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<a asp-action="CreateOrder">Создать заказ</a>
|
||||||
|
<a asp-action="UpdateOrder">Обновить заказ</a>
|
||||||
|
<a asp-action="DeleteOrder">Удалить заказ</a>
|
||||||
|
</p>
|
||||||
|
<table class="table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>
|
||||||
|
Номер
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
Дата создания
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
Статус
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
Сумма
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@foreach (var item in Model)
|
||||||
|
{
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
@Html.DisplayFor(modelItem => item.Id)
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@Html.DisplayFor(modelItem => item.DateCreate)
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@Html.DisplayFor(modelItem => item.Status)
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@Html.DisplayFor(modelItem => item.Sum)
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
|
75
ComputerShopImplementerApp/Views/Home/Requests.cshtml
Normal file
75
ComputerShopImplementerApp/Views/Home/Requests.cshtml
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
@using ComputerShopContracts.ViewModels
|
||||||
|
|
||||||
|
@model List<RequestViewModel>
|
||||||
|
@* !!!ТУТ СКОРЕЕ ВСЕГО НАДО ПОМЕНЯТЬ *@
|
||||||
|
@{
|
||||||
|
ViewData["Title"] = "Requests";
|
||||||
|
}
|
||||||
|
|
||||||
|
<div class="text-center">
|
||||||
|
<h1 class="display-4">Заявки на сборки</h1>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="text-center">
|
||||||
|
@{
|
||||||
|
if (Model == null)
|
||||||
|
{
|
||||||
|
<h3 class="display-4">Авторизируйтесь</h3>
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// !!!ДОБАВИТЬ ЭТИ МЕТОДЫ В HOME КОНТРОЛЛЕР И ТАКИЕ ЖЕ СТРАНИЦЫ
|
||||||
|
<p>
|
||||||
|
<a asp-action="CreateRequest">Создать заявку</a>
|
||||||
|
<a asp-action="ConnectRequestAssembly">Связать заявку со сборкой</a>
|
||||||
|
<a asp-action="UpdateRequest">Обновить заявку</a>
|
||||||
|
<a asp-action="DeleteRequest">Удалить заявку</a>
|
||||||
|
</p>
|
||||||
|
<table class="table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>
|
||||||
|
Номер
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
Дата оформления
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
ФИО клиента-заявителя
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
Название сборки
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
Стоимость сборки
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@foreach (var item in Model)
|
||||||
|
{
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
@Html.DisplayFor(modelItem => item.Id)
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@Html.DisplayFor(modelItem => item.DateRequest)
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@Html.DisplayFor(modelItem => item.ClientFIO)
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@Html.DisplayFor(modelItem => item.Assembly.AssemblyName)
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@Html.DisplayFor(modelItem => item.Assembly.Price)
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
62
ComputerShopImplementerApp/Views/Home/Shipments.cshtml
Normal file
62
ComputerShopImplementerApp/Views/Home/Shipments.cshtml
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
@using ComputerShopContracts.ViewModels
|
||||||
|
|
||||||
|
@model List<ShipmentViewModel>
|
||||||
|
@* !!!ТУТ СКОРЕЕ ВСЕГО НАДО ПОМЕНЯТЬ *@
|
||||||
|
@{
|
||||||
|
ViewData["Title"] = "Shipments";
|
||||||
|
}
|
||||||
|
|
||||||
|
<div class="text-center">
|
||||||
|
<h1 class="display-4">Партии товаров</h1>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="text-center">
|
||||||
|
@{
|
||||||
|
if (Model == null)
|
||||||
|
{
|
||||||
|
<h3 class="display-4">Авторизируйтесь</h3>
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// !!!ДОБАВИТЬ ЭТИ МЕТОДЫ В HOME КОНТРОЛЛЕР И ТАКИЕ ЖЕ СТРАНИЦЫ
|
||||||
|
<p>
|
||||||
|
<a asp-action="CreateShipment">Создать партию товаров</a>
|
||||||
|
<a asp-action="UpdateShipment">Обновить партию товаров</a>
|
||||||
|
<a asp-action="DeleteShipment">Удалить партию товаров</a>
|
||||||
|
</p>
|
||||||
|
<table class="table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>
|
||||||
|
Номер
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
Поставщик
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
Дата поставки
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@foreach (var item in Model)
|
||||||
|
{
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
@Html.DisplayFor(modelItem => item.Id)
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@Html.DisplayFor(modelItem => item.ProviderName)
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@Html.DisplayFor(modelItem => item.DateShipment)
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
107
ComputerShopImplementerApp/Views/Home/UpdateOrder.cshtml
Normal file
107
ComputerShopImplementerApp/Views/Home/UpdateOrder.cshtml
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
@using ComputerShopDataModels.Enums;
|
||||||
|
@{
|
||||||
|
ViewData["Title"] = "Update order";
|
||||||
|
}
|
||||||
|
|
||||||
|
<form method="post">
|
||||||
|
<div class="text-center">
|
||||||
|
<h2 class="display-4">Изменение заказа</h2>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="mb-3">Выберите заказ для изменения:</label>
|
||||||
|
<select id="order" name="order" class="form-control">
|
||||||
|
<option selected disabled>Выберите заказ</option>
|
||||||
|
@foreach (var order in ViewBag.Orders)
|
||||||
|
{
|
||||||
|
<option value="@order.Id">@order.DateCreate</option>
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
@*<select id="order" name="order" class="form-control" asp-items="@(new SelectList(ViewBag.Orders, "Id", "DateCreate"))"> <option selected disabled>Выберите заказ</option> </select>*@
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="mb-3">Новый статус заказа:</label>
|
||||||
|
<div class="mb-3">
|
||||||
|
<select id="status" name="status" class="form-control">
|
||||||
|
<option selected disabled>Выберите статус</option>
|
||||||
|
@{
|
||||||
|
foreach (var status in Enum.GetValues(typeof(OrderStatus)))
|
||||||
|
{
|
||||||
|
<option value="@status">@status</option>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="mb-3">Текущий статус заказа:</label>
|
||||||
|
@* <input class="mb-3" type="text" id="currentStatus" name="currentStatus" readonly /> *@
|
||||||
|
<span id="currentStatus" style="font-weight: bold;"></span>
|
||||||
|
</div>
|
||||||
|
@* <div class="row">
|
||||||
|
<div class="col-4 mb-3">Статус заказа:</div>
|
||||||
|
<div class="col-8 mb-3">
|
||||||
|
<select id="status" name="status" class="form-control">
|
||||||
|
@{
|
||||||
|
foreach (var status in Enum.GetValues(typeof(OrderStatus)))
|
||||||
|
{
|
||||||
|
<option value="@status">@status</option>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div> *@
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="mb-3">Дата создания:</label>
|
||||||
|
<input type="datetime-local" id="date" name="date" class="mb-3 form-control" step="1">
|
||||||
|
</div>
|
||||||
|
@* <div class="row">
|
||||||
|
<div class="col-4 mb-3">Дата создания:</div>
|
||||||
|
<div class="col-8 mb-3"><input type="datetime-local" id="date" name="date"></div>
|
||||||
|
</div> *@
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Сумма:</label>
|
||||||
|
@* <div class="col-8"><input type="text" id="sum" name="sum" readonly /></div> *@
|
||||||
|
<input type="number" id="sum" name="sum" readonly />
|
||||||
|
</div>
|
||||||
|
@* <div class="row mb-3">
|
||||||
|
<div class="col-4">Сумма:</div>
|
||||||
|
<div class="col-8"><input type="text" id="sum" name="sum" readonly /></div>
|
||||||
|
</div> *@
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-8"></div>
|
||||||
|
<div class="col-4"><input type="submit" value="Обновить" class="btn btn-primary" /></div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
|
||||||
|
<script>
|
||||||
|
$('#order').on('change', function () {
|
||||||
|
check();
|
||||||
|
});
|
||||||
|
var orderStatusNames = [
|
||||||
|
"Неизвестен",
|
||||||
|
"Принят",
|
||||||
|
"Выполняется",
|
||||||
|
"Готов",
|
||||||
|
"Выдан"
|
||||||
|
];
|
||||||
|
function check() {
|
||||||
|
var order = $('#order').val();
|
||||||
|
if (order) {
|
||||||
|
$.ajax({
|
||||||
|
method: "GET",
|
||||||
|
url: "/Home/GetOrder",
|
||||||
|
data: { orderId: order },
|
||||||
|
success: function (result) {
|
||||||
|
console.log(result);
|
||||||
|
var localDate = result.dateCreate.toLocaleString();
|
||||||
|
$("#date").val(localDate);
|
||||||
|
//!!!ТУТ КАК-ТО ВЫВЕСТИ СТАТУС
|
||||||
|
var orderStatusName = orderStatusNames[result.status + 1];
|
||||||
|
$("#currentStatus").text(orderStatusName);
|
||||||
|
$("#sum").val(result.sum);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
|
</script>
|
96
ComputerShopImplementerApp/Views/Home/UpdateRequest.cshtml
Normal file
96
ComputerShopImplementerApp/Views/Home/UpdateRequest.cshtml
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
@{
|
||||||
|
ViewData["Title"] = "Update request";
|
||||||
|
}
|
||||||
|
<div class="text-center">
|
||||||
|
<h2 class="display-4">Изменение заявки</h2>
|
||||||
|
</div>
|
||||||
|
<form method="post">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="mb-3">Выберите завку для изменения:</label>
|
||||||
|
<select id="request" name="request" class="form-control">
|
||||||
|
<option selected disabled>Выберите заявку</option>
|
||||||
|
@foreach (var request in ViewBag.Requests)
|
||||||
|
{
|
||||||
|
<option value="@request.Id">@request.DateRequest</option>
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="mb-3">Дата оформления:</label>
|
||||||
|
<input type="datetime-local" id="date" name="date" class="mb-3 form-control" step="1">
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="mb-3">ФИО клиента-заявителя:</label>
|
||||||
|
<input type="text" id="clientFIO" name="clientFIO" class="mb-3 form-control" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-6">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="mb-3">Заказы для заявки:</label>
|
||||||
|
<select multiple size="6" id="orders" name="orders" class="form-control">
|
||||||
|
@{
|
||||||
|
foreach (var order in ViewBag.Orders)
|
||||||
|
{
|
||||||
|
<option value="@order.Id">@order.DateCreate</option>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="mb-3">Текущие заказы заявки:</label>
|
||||||
|
@* !!!МБ УБРАТЬ disabled *@
|
||||||
|
<select multiple disabled size="6" id="currentOrders" name="currentOrders" class="form-control">
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-8"></div>
|
||||||
|
<div class="col-4"><input type="submit" value="Изменить" class="btn btn-primary" /></div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
|
||||||
|
<script>
|
||||||
|
$('#request').on('change', function () {
|
||||||
|
check();
|
||||||
|
});
|
||||||
|
function formatDate(date) {
|
||||||
|
var options = { year: 'numeric', month: 'numeric', day: 'numeric', hour: 'numeric', minute: 'numeric', second: 'numeric' };
|
||||||
|
return new Date(date).toLocaleString('ru-RU', options).replace(',', '')/*.replace(/\./g, '').replace(/\s/g, '.')*/;
|
||||||
|
}
|
||||||
|
function check() {
|
||||||
|
var request = $('#request').val();
|
||||||
|
if (request) {
|
||||||
|
$.ajax({
|
||||||
|
method: "GET",
|
||||||
|
url: "/Home/GetRequest",
|
||||||
|
data: { requestId: request },
|
||||||
|
success: function (result) {
|
||||||
|
console.log(result);
|
||||||
|
var localDate = result.dateRequest.toLocaleString();
|
||||||
|
$("#date").val(localDate);
|
||||||
|
$("#clientFIO").val(result.clientFIO);
|
||||||
|
|
||||||
|
$('#currentOrders').empty();
|
||||||
|
// Перебор свойств объекта requestOrders
|
||||||
|
for (var orderId in result.requestOrders) {
|
||||||
|
if (result.requestOrders.hasOwnProperty(orderId)) {
|
||||||
|
var order = result.requestOrders[orderId];
|
||||||
|
var localDate = formatDate(order.dateCreate);
|
||||||
|
$('#currentOrders').append($('<option>', {
|
||||||
|
value: orderId,
|
||||||
|
text: localDate
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
|
</script>
|
103
ComputerShopImplementerApp/Views/Home/UpdateShipment.cshtml
Normal file
103
ComputerShopImplementerApp/Views/Home/UpdateShipment.cshtml
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
@{
|
||||||
|
ViewData["Title"] = "Update shipment";
|
||||||
|
}
|
||||||
|
<div class="text-center">
|
||||||
|
<h2 class="display-4">Изменение партии товаров</h2>
|
||||||
|
</div>
|
||||||
|
<form method="post">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="mb-3">Выберите заказ для изменения:</label>
|
||||||
|
<select id="shipment" name="shipment" class="form-control">
|
||||||
|
<option selected disabled>Выберите партию товаров</option>
|
||||||
|
@foreach (var shipment in ViewBag.Shipments)
|
||||||
|
{
|
||||||
|
<option value="@shipment.Id">@shipment.DateShipment</option>
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="mb-3">Поставщик:</label>
|
||||||
|
<input type="text" id="providerName" name="providerName" class="mb-3 form-control" />
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="mb-3">Дата доставки партии:</label>
|
||||||
|
<input type="datetime-local" id="date" name="date" class="mb-3 form-control" step="1">
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-6">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="mb-3">Заказы для партии:</label>
|
||||||
|
<select multiple size="6" id="orders" name="orders" class="form-control">
|
||||||
|
@{
|
||||||
|
foreach (var order in ViewBag.Orders)
|
||||||
|
{
|
||||||
|
<option value="@order.Id">@order.DateCreate</option>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="mb-3">Текущие заказы партии:</label>
|
||||||
|
@* !!!МБ УБРАТЬ disabled *@
|
||||||
|
<select multiple disabled size="6" id="currentOrders" name="currentOrders" class="form-control">
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-8"></div>
|
||||||
|
<div class="col-4"><input type="submit" value="Изменить" class="btn btn-primary" /></div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
|
||||||
|
<script>
|
||||||
|
$('#shipment').on('change', function () {
|
||||||
|
check();
|
||||||
|
});
|
||||||
|
function formatDate(date) {
|
||||||
|
var options = { year: 'numeric', month: 'numeric', day: 'numeric', hour: 'numeric', minute: 'numeric', second: 'numeric' };
|
||||||
|
return new Date(date).toLocaleString('ru-RU', options).replace(',', '')/*.replace(/\./g, '').replace(/\s/g, '.')*/;
|
||||||
|
}
|
||||||
|
// function formatDate(date) {
|
||||||
|
// // var datePart = new Date(date).toLocaleDateString('ru-RU', { year: 'numeric', month: '2-digit', day: '2-digit' }).replace(/\./g, '').replace(/\g, '.');
|
||||||
|
// // var timePart = new Date(date).toLocaleTimeString('ru-RU', { hour: '2-digit', minute: '2-digit', second: '2-digit' }).replace(/:/g, '');
|
||||||
|
// // return datePart + ' ' + timePart;
|
||||||
|
// var datePart = new Date(date).toLocaleDateString('ru-RU', { year: '2-digit', month: '2-digit', day: '2-digit' }).replace(/\./g, '').replace(/\//g, '.');
|
||||||
|
// var timePart = new Date(date).toLocaleTimeString('ru-RU', { hour: '2-digit', minute: '2-digit', second: '2-digit' }).replace(/:/g, '');
|
||||||
|
// return datePart.replace(/$/, '. ') + timePart;
|
||||||
|
// }
|
||||||
|
function check() {
|
||||||
|
var shipment = $('#shipment').val();
|
||||||
|
if (shipment) {
|
||||||
|
$.ajax({
|
||||||
|
method: "GET",
|
||||||
|
url: "/Home/GetShipment",
|
||||||
|
data: { shipmentId: shipment },
|
||||||
|
success: function (result) {
|
||||||
|
console.log(result);
|
||||||
|
var localDate = result.dateShipment.toLocaleString();
|
||||||
|
$("#date").val(localDate);
|
||||||
|
$("#providerName").val(result.providerName);
|
||||||
|
|
||||||
|
$('#currentOrders').empty();
|
||||||
|
// Перебор свойств объекта shipmentOrders
|
||||||
|
for (var orderId in result.shipmentOrders) {
|
||||||
|
if (result.shipmentOrders.hasOwnProperty(orderId)) {
|
||||||
|
var order = result.shipmentOrders[orderId];
|
||||||
|
var localDate = formatDate(order.dateCreate);
|
||||||
|
$('#currentOrders').append($('<option>', {
|
||||||
|
value: orderId,
|
||||||
|
text: localDate
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
|
</script>
|
@ -17,10 +17,20 @@
|
|||||||
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target=".navbar-collapse" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
|
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target=".navbar-collapse" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
|
||||||
<span class="navbar-toggler-icon"></span>
|
<span class="navbar-toggler-icon"></span>
|
||||||
</button>
|
</button>
|
||||||
|
@* !!!Тут изменять asp-action и мб удалить "Личные данные" *@
|
||||||
<div class="navbar-collapse collapse d-sm-inline-flex flex-sm-row-reverse">
|
<div class="navbar-collapse collapse d-sm-inline-flex flex-sm-row-reverse">
|
||||||
<ul class="navbar-nav flex-grow-1">
|
<ul class="navbar-nav flex-grow-1">
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Заказы</a>
|
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Главная</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Orders">Заказы</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Shipments">Партии товаров</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Requests">Заявки</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Личные данные</a>
|
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Личные данные</a>
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
<ProjectReference Include="..\ComputerShopBusinessLogic\ComputerShopBusinessLogic.csproj" />
|
<ProjectReference Include="..\ComputerShopBusinessLogic\ComputerShopBusinessLogic.csproj" />
|
||||||
<ProjectReference Include="..\ComputerShopContracts\ComputerShopContracts.csproj" />
|
<ProjectReference Include="..\ComputerShopContracts\ComputerShopContracts.csproj" />
|
||||||
<ProjectReference Include="..\ComputerShopDatabaseImplement\ComputerShopDatabaseImplement.csproj" />
|
<ProjectReference Include="..\ComputerShopDatabaseImplement\ComputerShopDatabaseImplement.csproj" />
|
||||||
|
<ProjectReference Include="..\ComputerShopImplementerApp\ComputerShopImplementerApp.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -3,6 +3,7 @@ using ComputerShopContracts.BusinessLogicContracts;
|
|||||||
using ComputerShopContracts.SearchModels;
|
using ComputerShopContracts.SearchModels;
|
||||||
using ComputerShopContracts.ViewModels;
|
using ComputerShopContracts.ViewModels;
|
||||||
using ComputerShopDatabaseImplement.Models;
|
using ComputerShopDatabaseImplement.Models;
|
||||||
|
using ComputerShopDataModels.Enums;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
namespace ComputerShopRestApi.Controllers
|
namespace ComputerShopRestApi.Controllers
|
||||||
@ -57,6 +58,16 @@ namespace ComputerShopRestApi.Controllers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//МБ ИЗМЕНИТЬ IEnumerable на List
|
||||||
|
//!!!ПОТОМ УДАЛИТЬ
|
||||||
|
//[HttpGet]
|
||||||
|
//public IEnumerable<string> GetOrderStatuses()
|
||||||
|
//{
|
||||||
|
// // Получаем все значения из перечисления и возвращаем как список строк
|
||||||
|
// var allStatuses = Enum.GetValues(typeof(OrderStatus)).Cast<OrderStatus>().Select(status => status.ToString());
|
||||||
|
// return allStatuses;
|
||||||
|
//}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public void CreateOrder(OrderBindingModel model)
|
public void CreateOrder(OrderBindingModel model)
|
||||||
{
|
{
|
||||||
@ -84,7 +95,8 @@ namespace ComputerShopRestApi.Controllers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpDelete]
|
//[HttpDelete]
|
||||||
|
[HttpPost]
|
||||||
public void DeleteOrder(OrderBindingModel model)
|
public void DeleteOrder(OrderBindingModel model)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -102,7 +102,7 @@ namespace ComputerShopRestApi.Controllers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpDelete]
|
[HttpPost]
|
||||||
public void DeleteRequest(RequestBindingModel model)
|
public void DeleteRequest(RequestBindingModel model)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -87,7 +87,7 @@ namespace ComputerShopRestApi.Controllers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpDelete]
|
[HttpPost]
|
||||||
public void DeleteShipment(ShipmentBindingModel model)
|
public void DeleteShipment(ShipmentBindingModel model)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -2,12 +2,18 @@ using ComputerShopBusinessLogic.BusinessLogics;
|
|||||||
using ComputerShopContracts.BusinessLogicContracts;
|
using ComputerShopContracts.BusinessLogicContracts;
|
||||||
using ComputerShopContracts.StorageContracts;
|
using ComputerShopContracts.StorageContracts;
|
||||||
using ComputerShopDatabaseImplement.Implements;
|
using ComputerShopDatabaseImplement.Implements;
|
||||||
|
using ComputerShopDatabaseImplement.Models;
|
||||||
|
using ComputerShopDataModels.Models;
|
||||||
using Microsoft.OpenApi.Models;
|
using Microsoft.OpenApi.Models;
|
||||||
|
|
||||||
var Builder = WebApplication.CreateBuilder(args);
|
var Builder = WebApplication.CreateBuilder(args);
|
||||||
Builder.Logging.SetMinimumLevel(LogLevel.Trace);
|
Builder.Logging.SetMinimumLevel(LogLevel.Trace);
|
||||||
Builder.Logging.AddLog4Net("log4net.config");
|
Builder.Logging.AddLog4Net("log4net.config");
|
||||||
|
|
||||||
|
//!!!ÌÁ ÓÄÀËÈÒÜ
|
||||||
|
//Builder.Services.AddTransient<IOrderModel, Order>();
|
||||||
|
//Builder.Services.AddTransient<IShipmentModel, Shipment>();
|
||||||
|
//Builder.Services.AddTransient<IRequestModel, Request>();
|
||||||
|
|
||||||
Builder.Services.AddTransient<IUserStorage, UserStorage>();
|
Builder.Services.AddTransient<IUserStorage, UserStorage>();
|
||||||
Builder.Services.AddTransient<IShipmentStorage, ShipmentStorage>();
|
Builder.Services.AddTransient<IShipmentStorage, ShipmentStorage>();
|
||||||
|
Loading…
Reference in New Issue
Block a user