Ладно
This commit is contained in:
parent
9ffb97cbd0
commit
05b0fb35d6
@ -10,7 +10,9 @@ namespace Contracts.SearchModels
|
||||
{
|
||||
public Guid? Id { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public double? Price { get; set; }
|
||||
public double? Rate { get; set; }
|
||||
public double? PriceFrom { get; set; }
|
||||
public double? PriceTo { get; set; }
|
||||
public double? RateFrom { get; set; }
|
||||
public double? RateTo { get; set; }
|
||||
}
|
||||
}
|
||||
|
72
DatabaseImplement/Implements/ProductStorage.cs
Normal file
72
DatabaseImplement/Implements/ProductStorage.cs
Normal file
@ -0,0 +1,72 @@
|
||||
using Contracts.BindingModels;
|
||||
using Contracts.SearchModels;
|
||||
using Contracts.StorageContracts;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DatabaseImplement.Implements
|
||||
{
|
||||
public class ProductStorage : IProductStorage
|
||||
{
|
||||
public ProductBindingModel? Delete(ProductSearchModel model)
|
||||
{
|
||||
if (model.Id is null && model.Name is null && model.Price is null && model.Rate is null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var context = new Database();
|
||||
var product = context.Products.FirstOrDefault(p =>
|
||||
(model.Id.HasValue && p.Id == model.Id) || (!string.IsNullOrEmpty(p.Name) && p.Name.Contains(model.Name)));
|
||||
|
||||
if (product is null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
context.Remove(product);
|
||||
context.SaveChanges();
|
||||
|
||||
return product.GetBindingModel();
|
||||
}
|
||||
|
||||
public ProductBindingModel? GetElement(ProductSearchModel model)
|
||||
{
|
||||
if (model.Id is null && string.IsNullOrWhiteSpace(model.Name))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var context = new Database();
|
||||
return context.Products
|
||||
.FirstOrDefault(prod => (model.Id.HasValue && prod.Id == model.Id)
|
||||
|| (!string.IsNullOrWhiteSpace(model.Name) && prod.Name.Contains(model.Name)))?.GetBindingModel();
|
||||
}
|
||||
|
||||
public IEnumerable<ProductBindingModel> GetList(ProductSearchModel? model)
|
||||
{
|
||||
if (model.Id is null && string.IsNullOrWhiteSpace(model.Name) || model.RateFrom > model.RateTo)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var context = new Database();
|
||||
return context.Products
|
||||
.Where(prod => (model.Id.HasValue && prod.Id == model.Id)
|
||||
|| (!string.IsNullOrWhiteSpace(model.Name) && prod.Name.Contains(model.Name))
|
||||
|| ((model.RateFrom.HasValue && model.RateTo.HasValue) && ((model.RateFrom < prod.Rate && prod.Rate < model.RateTo)))
|
||||
|| ((model.PriceFrom.HasValue && model.PriceTo.HasValue) && ((model.PriceFrom < prod.Price && prod.Price < model.PriceTo))))
|
||||
.Select(r => r.GetBindingModel()); ;
|
||||
}
|
||||
|
||||
public ProductBindingModel? Insert(ProductBindingModel model)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public ProductBindingModel? Update(ProductBindingModel model)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
39
DatabaseImplement/Implements/PurchaseStorage.cs
Normal file
39
DatabaseImplement/Implements/PurchaseStorage.cs
Normal file
@ -0,0 +1,39 @@
|
||||
using Contracts.BindingModels;
|
||||
using Contracts.SearchModels;
|
||||
using Contracts.StorageContracts;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DatabaseImplement.Implements
|
||||
{
|
||||
public class PurchaseStorage : IPurchaseStorage
|
||||
{
|
||||
public PurchaseBindingModel? Delete(PurchaseSearchModel model)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public PurchaseBindingModel? GetElement(PurchaseSearchModel model)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IEnumerable<PurchaseBindingModel> GetList(PurchaseSearchModel? model)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public PurchaseBindingModel? Insert(PurchaseBindingModel model)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public PurchaseBindingModel? Update(PurchaseBindingModel model)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
39
DatabaseImplement/Implements/SellStorage.cs
Normal file
39
DatabaseImplement/Implements/SellStorage.cs
Normal file
@ -0,0 +1,39 @@
|
||||
using Contracts.BindingModels;
|
||||
using Contracts.SearchModels;
|
||||
using Contracts.StorageContracts;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DatabaseImplement.Implements
|
||||
{
|
||||
public class SellStorage : ISellStorage
|
||||
{
|
||||
public SellBindingModel? Delete(SellSearchModel model)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public SellBindingModel? GetElement(SellSearchModel model)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IEnumerable<SellBindingModel> GetList(SellSearchModel? model)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public SellBindingModel? Insert(SellBindingModel model)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public SellBindingModel? Update(SellBindingModel model)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user