Mochalov D.V. LabWork05_Hard #13

Closed
b0n3l3sS wants to merge 63 commits from LabWork05_Hard into LabWork05_Base
4 changed files with 34 additions and 2 deletions
Showing only changes of commit 5b5b8cc6ac - Show all commits

View File

@ -154,6 +154,10 @@ namespace LawFirmBusinessLogic.BusinessLogics
{
throw new ArgumentNullException("Нет названия магазина!", nameof(model.Name));
}
if (model.MaxCountDocuments < 0)
{
throw new InvalidOperationException("Магазин с отрицательным количеством максимального количества документов!");
}
_logger.LogInformation("Shop. Name: {0}, Adress: {1}, ID: {2}", model.Name, model.Adress, model.Id);
var element = _shopStorage.GetElement(new ShopSearchModel
{

View File

@ -11,6 +11,27 @@ using System.Threading.Tasks;
namespace LawFirmFileImplement.Implements
{
// Нужно узнать, проверять ли на наличие всех товаров, или только
// наличие определенного товара
// То же самое с продажей
public class ShopStorage : IShopStorage
{
private readonly DataFileSingleton source;

View File

@ -109,7 +109,7 @@ namespace LawFirmFileImplement.Models
new XAttribute("Id", Id),
new XElement("Name", Name),
new XElement("Address", Adress),
new XElement("MaxCountDocuments", MaxCountDocuments.ToString()),
new XElement("MaxCountDocuments", MaxCountDocuments),
new XElement("OpeningDate", OpeningDate.ToString()),
new XElement("ShopDocuments", Documents.Select (x =>
new XElement("ShopDocument",

View File

@ -21,6 +21,8 @@ namespace LawFirmListImplements.Models
public DateTime OpeningDate { get; private set; }
public int MaxCountDocuments { get; private set; }
public Dictionary<int, (IDocumentModel, int)> ShopDocuments { get; private set; } = new();
public static Shop? Create (ShopBindingModel model)
@ -35,6 +37,7 @@ namespace LawFirmListImplements.Models
Name = model.Name,
Adress = model.Adress,
OpeningDate = model.OpeningDate,
MaxCountDocuments = model.MaxCountDocuments,
ShopDocuments = new()
};
}
@ -49,6 +52,7 @@ namespace LawFirmListImplements.Models
Adress = model.Adress;
OpeningDate = model.OpeningDate;
ShopDocuments = model.ShopDocuments;
MaxCountDocuments= model.MaxCountDocuments;
}
public ShopViewModel GetViewModel => new()
@ -57,7 +61,10 @@ namespace LawFirmListImplements.Models
Name = Name,
Adress = Adress,
OpeningDate = OpeningDate,
ShopDocuments = ShopDocuments
ShopDocuments = ShopDocuments,
MaxCountDocuments = MaxCountDocuments
};
}
}