Осталось еще всего лишь сделать примерно 95% от всей работы
This commit is contained in:
parent
cb37c8ab52
commit
258dd5055d
12
BusinessLogic/BusinessLogic/SellLogic.cs
Normal file
12
BusinessLogic/BusinessLogic/SellLogic.cs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace BusinessLogic.BusinessLogic
|
||||||
|
{
|
||||||
|
internal class SellLogic
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
@ -12,8 +12,8 @@ namespace Contracts.BindingModels
|
|||||||
{
|
{
|
||||||
public Guid Id { get; set; }
|
public Guid Id { get; set; }
|
||||||
public DateTime DatePurchase { get; set; }
|
public DateTime DatePurchase { get; set; }
|
||||||
public required IUser User { get; set; }
|
public Guid UserId { get; set; }
|
||||||
public required List<IProduct> Products { get; set; }
|
|
||||||
public PurchaseStatus Status { get; set; }
|
public PurchaseStatus Status { get; set; }
|
||||||
|
public Dictionary<Guid, (IProduct, int)> PurchaseProducts { get; set; } = new();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,16 +14,16 @@ namespace Contracts.Converters
|
|||||||
{
|
{
|
||||||
Id = model.Id,
|
Id = model.Id,
|
||||||
DatePurchase = model.DatePurchase,
|
DatePurchase = model.DatePurchase,
|
||||||
User = model.User,
|
UserId = model.UserId,
|
||||||
Products = model.Products,
|
PurchaseProducts = model.PurchaseProducts,
|
||||||
};
|
};
|
||||||
|
|
||||||
public static PurchaseBindingModel ToBinding(PurchaseViewModel model) => new()
|
public static PurchaseBindingModel ToBinding(PurchaseViewModel model) => new()
|
||||||
{
|
{
|
||||||
Id = model.Id,
|
Id = model.Id,
|
||||||
DatePurchase = model.DatePurchase,
|
DatePurchase = model.DatePurchase,
|
||||||
User = model.User,
|
UserId = model.UserId,
|
||||||
Products = model.Products,
|
PurchaseProducts = model.PurchaseProducts,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
13
Contracts/Converters/SellConverter.cs
Normal file
13
Contracts/Converters/SellConverter.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Contracts.Converters
|
||||||
|
{
|
||||||
|
public class SellConverter
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -12,8 +12,9 @@ namespace Contracts.ViewModels
|
|||||||
{
|
{
|
||||||
public Guid Id { get; set; }
|
public Guid Id { get; set; }
|
||||||
public DateTime DatePurchase { get; set; }
|
public DateTime DatePurchase { get; set; }
|
||||||
public required IUser User { get; set; }
|
public required Guid UserId { get; set; }
|
||||||
public required List<IProduct> Products { get; set; }
|
|
||||||
public PurchaseStatus Status { get; set; }
|
public PurchaseStatus Status { get; set; }
|
||||||
}
|
public Dictionary<Guid, (IProduct, int)> PurchaseProducts { get; set; } = new()
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,8 +13,8 @@ namespace DatabaseImplement.Implements
|
|||||||
{
|
{
|
||||||
public SellBindingModel? Delete(SellSearchModel model)
|
public SellBindingModel? Delete(SellSearchModel model)
|
||||||
{
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public SellBindingModel? GetElement(SellSearchModel model)
|
public SellBindingModel? GetElement(SellSearchModel model)
|
||||||
{
|
{
|
||||||
|
@ -83,7 +83,6 @@ namespace DatabaseImplement.Models
|
|||||||
IsBeingSold = model.IsBeingSold;
|
IsBeingSold = model.IsBeingSold;
|
||||||
Amount = model.Amount;
|
Amount = model.Amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProductViewModel GetViewModel
|
public ProductViewModel GetViewModel
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
@ -2,10 +2,13 @@
|
|||||||
using Contracts.ViewModels;
|
using Contracts.ViewModels;
|
||||||
using DataModels.Enums;
|
using DataModels.Enums;
|
||||||
using DataModels.Models;
|
using DataModels.Models;
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata.Internal;
|
||||||
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.Runtime.Serialization;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
@ -16,25 +19,63 @@ namespace DatabaseImplement.Models
|
|||||||
public Guid Id { get; set; }
|
public Guid Id { get; set; }
|
||||||
[Required]
|
[Required]
|
||||||
public DateTime DatePurchase { get; set; }
|
public DateTime DatePurchase { get; set; }
|
||||||
[Required]
|
[Required]
|
||||||
public PurchaseStatus Status { get; private set; } = PurchaseStatus.Unknown;
|
public Guid UserId { get; set; }
|
||||||
public PurchaseBindingModel GetBindingModel() => new()
|
[Required]
|
||||||
|
public PurchaseStatus Status { get; private set; } = PurchaseStatus.Unknown;
|
||||||
|
private Dictionary<Guid, (IProduct, int)>? _purchaseProducts = null;
|
||||||
|
public virtual User? User { get; set; }
|
||||||
|
[DataMember]
|
||||||
|
[NotMapped]
|
||||||
|
public Dictionary<Guid, (IProduct, int)> PurchaseProducts
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_purchaseProducts == null)
|
||||||
|
{
|
||||||
|
_purchaseProducts = Products.ToDictionary(e => e.ProductId, e => (e.Product as IProduct, e.Count));
|
||||||
|
}
|
||||||
|
return _purchaseProducts;
|
||||||
|
}
|
||||||
|
set { }
|
||||||
|
}
|
||||||
|
[ForeignKey("PurchaseId")]
|
||||||
|
public virtual List<PurchaseProducts> Products { get; set; } = new();
|
||||||
|
public PurchaseBindingModel GetBindingModel() => new()
|
||||||
{
|
{
|
||||||
Id = Id,
|
Id = Id,
|
||||||
DatePurchase = DatePurchase
|
DatePurchase = DatePurchase,
|
||||||
|
UserId = UserId,
|
||||||
|
PurchaseProducts = PurchaseProducts,
|
||||||
|
Status = Status
|
||||||
};
|
};
|
||||||
|
|
||||||
public static Purchase ToPurchaseFromView(PurchaseViewModel model, Purchase purchase) => new()
|
public PurchaseViewModel GetViewModel() => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
DatePurchase = DatePurchase,
|
||||||
|
UserId = UserId,
|
||||||
|
PurchaseProducts = PurchaseProducts,
|
||||||
|
Status = Status
|
||||||
|
};
|
||||||
|
|
||||||
|
public static Purchase ToPurchaseFromView(PurchaseViewModel model, Purchase purchase) => new()
|
||||||
{
|
{
|
||||||
Id = model.Id,
|
Id = model.Id,
|
||||||
DatePurchase = model.DatePurchase
|
DatePurchase = model.DatePurchase,
|
||||||
};
|
UserId = model.UserId,
|
||||||
|
PurchaseProducts = model.PurchaseProducts,
|
||||||
|
Status = model.Status
|
||||||
|
};
|
||||||
|
|
||||||
public static Purchase ToPurchaseFromBinding(PurchaseBindingModel model, Purchase purchase) => new()
|
public static Purchase ToPurchaseFromBinding(PurchaseBindingModel model, Purchase purchase) => new()
|
||||||
{
|
{
|
||||||
Id = model.Id,
|
Id = model.Id,
|
||||||
DatePurchase = model.DatePurchase,
|
DatePurchase = model.DatePurchase,
|
||||||
};
|
UserId = model.UserId,
|
||||||
|
PurchaseProducts = model.PurchaseProducts,
|
||||||
|
Status = model.Status
|
||||||
|
};
|
||||||
|
|
||||||
public void Update(PurchaseBindingModel model, Purchase purchase)
|
public void Update(PurchaseBindingModel model, Purchase purchase)
|
||||||
{
|
{
|
||||||
|
23
DatabaseImplement/Models/PurchaseProducts.cs
Normal file
23
DatabaseImplement/Models/PurchaseProducts.cs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DatabaseImplement.Models
|
||||||
|
{
|
||||||
|
public class PurchaseProducts
|
||||||
|
{
|
||||||
|
public Guid Guid { get; set; }
|
||||||
|
[Required]
|
||||||
|
public Guid PurchaseId { get; set; }
|
||||||
|
[Required]
|
||||||
|
public Guid ProductId { get; set; }
|
||||||
|
[Required]
|
||||||
|
public int Count { get; set; }
|
||||||
|
public virtual Product Product { get; set; } = new();
|
||||||
|
public virtual Purchase Purchase { get; set; } = new();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
4
WebApp/Pages/Cart.cshtml
Normal file
4
WebApp/Pages/Cart.cshtml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
@page
|
||||||
|
@model WebApp.Pages.CartModel
|
||||||
|
@{
|
||||||
|
}
|
13
WebApp/Pages/Cart.cshtml.cs
Normal file
13
WebApp/Pages/Cart.cshtml.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||||
|
|
||||||
|
namespace WebApp.Pages
|
||||||
|
{
|
||||||
|
public class CartModel : PageModel
|
||||||
|
{
|
||||||
|
public void OnGet()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
4
WebApp/Pages/Catalog.cshtml
Normal file
4
WebApp/Pages/Catalog.cshtml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
@page
|
||||||
|
@model WebApp.Pages.CatalogModel
|
||||||
|
@{
|
||||||
|
}
|
12
WebApp/Pages/Catalog.cshtml.cs
Normal file
12
WebApp/Pages/Catalog.cshtml.cs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||||
|
|
||||||
|
namespace WebApp.Pages
|
||||||
|
{
|
||||||
|
public class CatalogModel : PageModel
|
||||||
|
{
|
||||||
|
public void OnGet()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user