public StoreItemAvailabilityReadModel(StoreItemStoreReadModel store, float price, StoreSectionReadModel defaultSection) { Store = store; Price = price; DefaultSection = defaultSection; }
public StoreItemReadModel ToSimpleReadModel(IStoreItem item, IItemCategory itemCategory, IManufacturer manufacturer, IStore store) { var manufacturerReadModel = manufacturer == null ? null : new ManufacturerReadModel( manufacturer.Id, manufacturer.Name, manufacturer.IsDeleted); var itemCategoryReadModel = itemCategory == null ? null : new ItemCategoryReadModel( itemCategory.Id, itemCategory.Name, itemCategory.IsDeleted); var section = store.Sections.First(); var storeSectionReadModel = new StoreSectionReadModel( section.Id, section.Name, section.SortingIndex, section.IsDefaultSection); var storeReadModel = new StoreItemStoreReadModel( store.Id, store.Name, storeSectionReadModel.ToMonoList()); var availability = item.Availabilities.First(); var availabilityReadModel = new StoreItemAvailabilityReadModel( storeReadModel, availability.Price, storeSectionReadModel); return(new StoreItemReadModel( item.Id, item.Name, item.IsDeleted, item.Comment, item.IsTemporary, new QuantityTypeReadModel( (int)item.QuantityType, item.QuantityType.ToString(), item.QuantityType.GetAttribute <DefaultQuantityAttribute>().DefaultQuantity, item.QuantityType.GetAttribute <PriceLabelAttribute>().PriceLabel, item.QuantityType.GetAttribute <QuantityLabelAttribute>().QuantityLabel, item.QuantityType.GetAttribute <QuantityNormalizerAttribute>().Value), item.QuantityInPacket, new QuantityTypeInPacketReadModel( (int)item.QuantityTypeInPacket, item.QuantityTypeInPacket.ToString(), item.QuantityTypeInPacket.GetAttribute <QuantityLabelAttribute>().QuantityLabel), itemCategoryReadModel, manufacturerReadModel, availabilityReadModel.ToMonoList())); }
public ItemSearchReadModel(ItemId id, string name, int defaultQuantity, float price, ManufacturerReadModel manufacturer, ItemCategoryReadModel itemCategory, StoreSectionReadModel defaultSection) { Id = id; Name = name; DefaultQuantity = defaultQuantity; Price = price; Manufacturer = manufacturer; ItemCategory = itemCategory; DefaultSection = defaultSection; }
public IEnumerable <ItemSearchReadModel> ToSimpleReadModels(IEnumerable <IStoreItem> items, IStore store, Dictionary <ItemCategoryId, IItemCategory> itemCategories, Dictionary <ManufacturerId, IManufacturer> manufacturers) { foreach (IStoreItem item in items) { ManufacturerReadModel manufacturerReadModel = null; ItemCategoryReadModel itemCategoryReadModel = null; if (item.ManufacturerId != null) { var manufacturer = manufacturers[item.ManufacturerId]; manufacturerReadModel = new ManufacturerReadModel( manufacturer.Id, manufacturer.Name, manufacturer.IsDeleted); } if (item.ItemCategoryId != null) { var itemCategory = itemCategories[item.ItemCategoryId]; itemCategoryReadModel = new ItemCategoryReadModel( itemCategory.Id, itemCategory.Name, itemCategory.IsDeleted); } var availability = item.Availabilities.Single(av => av.StoreId == store.Id); var section = store.Sections.Single(s => s.Id == availability.DefaultSectionId); var sectionReadModel = new StoreSectionReadModel(section.Id, section.Name, section.SortingIndex, section.IsDefaultSection); yield return(new ItemSearchReadModel( item.Id, item.Name, item.QuantityType.GetAttribute <DefaultQuantityAttribute>().DefaultQuantity, availability.Price, manufacturerReadModel, itemCategoryReadModel, sectionReadModel)); } }