Фиксы

This commit is contained in:
Данила Мочалов 2023-02-27 08:49:14 +04:00
parent faef920c50
commit 5b5b8cc6ac
4 changed files with 34 additions and 2 deletions

View File

@ -154,6 +154,10 @@ namespace LawFirmBusinessLogic.BusinessLogics
{ {
throw new ArgumentNullException("Нет названия магазина!", nameof(model.Name)); 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); _logger.LogInformation("Shop. Name: {0}, Adress: {1}, ID: {2}", model.Name, model.Adress, model.Id);
var element = _shopStorage.GetElement(new ShopSearchModel var element = _shopStorage.GetElement(new ShopSearchModel
{ {

View File

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

View File

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

View File

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