public StoreItemContract ToContract(StoreItemReadModel source) { if (source is null) { throw new ArgumentNullException(nameof(source)); } ItemCategoryContract itemCategoryContract = null; if (source.ItemCategory != null) { itemCategoryContract = itemCategoryContractConverter.ToContract(source.ItemCategory); } ManufacturerContract manufacturerContract = null; if (source.Manufacturer != null) { manufacturerContract = manufacturerContractConverter.ToContract(source.Manufacturer); } return(new StoreItemContract( source.Id.Value, source.Name, source.IsDeleted, source.Comment, source.IsTemporary, quantityTypeContractConverter.ToContract(source.QuantityType), source.QuantityInPacket, quantityTypeInPacketContractConverter.ToContract(source.QuantityTypeInPacket), itemCategoryContract, manufacturerContract, storeItemAvailabilityContractConverter.ToContract(source.Availabilities))); }
private T_Item_CategoryEntity Convert(ItemCategoryContract contract) { var dbEntity = new T_Item_CategoryEntity { item_category_id = contract.ItemCategoryId, item_category_code = contract.ItemCategoryCode, item_category_name = contract.ItemCategoryName, status = contract.Status, parent_id = string.IsNullOrEmpty(contract.ParentId) ? ConfigMgr.HeadItemCategoryId : contract.ParentId, create_time = contract.CreateTime != null?contract.CreateTime.Value.ToString("yyyy-MM-dd hh:mm:ss") : null, modify_time = contract.ModifyTime != null?contract.ModifyTime.Value.ToString("yyyy-MM-dd hh:mm:ss") : null, DisplayIndex = contract.DisplayIndex, CustomerID = ConfigMgr.CustomerId }; return(dbEntity); }
public void Deal(ItemCategoryContract contract) { var dbEntity = Convert(contract); var facade = new T_Item_CategoryFacade(); switch (contract.Operation) { case OptEnum.Create: facade.Create(dbEntity); break; case OptEnum.Update: facade.Update(dbEntity); break; case OptEnum.Delete: facade.Delete(dbEntity); break; } }
public ShoppingListItemContract ToContract(ShoppingListItemReadModel source) { if (source is null) { throw new System.ArgumentNullException(nameof(source)); } ItemCategoryContract itemCategoryContract = null; if (source.ItemCategory != null) { itemCategoryContract = itemCategoryContractConverter.ToContract(source.ItemCategory); } ManufacturerContract manufacturerContract = null; if (source.Manufacturer != null) { manufacturerContract = manufacturerContractConverter.ToContract(source.Manufacturer); } QuantityTypeContract quantityTypeContract = quantityTypeContractConverter.ToContract(source.QuantityType); QuantityTypeInPacketContract quantityTypeInPacketContract = quantityTypeInPacketContractConverter.ToContract(source.QuantityTypeInPacket); return(new ShoppingListItemContract( source.Id.Value, source.Name, source.IsDeleted, source.Comment, source.IsTemporary, source.PricePerQuantity, quantityTypeContract, source.QuantityInPacket, quantityTypeInPacketContract, itemCategoryContract, manufacturerContract, source.IsInBasket, source.Quantity)); }
public StoreItemContract(int id, string name, bool isDeleted, string comment, bool isTemporary, QuantityTypeContract quantityType, float quantityInPacket, QuantityTypeInPacketContract quantityTypeInPacket, ItemCategoryContract itemCategory, ManufacturerContract manufacturer, IEnumerable <StoreItemAvailabilityContract> availabilities) { if (string.IsNullOrEmpty(name)) { throw new System.ArgumentException($"'{nameof(name)}' cannot be null or empty", nameof(name)); } Id = id; Name = name; IsDeleted = isDeleted; Comment = comment; IsTemporary = isTemporary; QuantityType = quantityType ?? throw new System.ArgumentNullException(nameof(quantityType)); QuantityInPacket = quantityInPacket; QuantityTypeInPacket = quantityTypeInPacket ?? throw new System.ArgumentNullException(nameof(quantityTypeInPacket)); ItemCategory = itemCategory; Manufacturer = manufacturer; this.availabilities = availabilities ?? throw new System.ArgumentNullException(nameof(availabilities)); }
public ShoppingListItemContract(int id, string name, bool isDeleted, string comment, bool isTemporary, float pricePerQuantity, QuantityTypeContract quantityType, float quantityInPacket, QuantityTypeInPacketContract quantityTypeInPacket, ItemCategoryContract itemCategory, ManufacturerContract manufacturer, bool isInBasket, float quantity) { if (string.IsNullOrWhiteSpace(name)) { throw new System.ArgumentException($"'{nameof(name)}' cannot be null or whitespace", nameof(name)); } Id = id; Name = name; IsDeleted = isDeleted; Comment = comment; IsTemporary = isTemporary; PricePerQuantity = pricePerQuantity; QuantityType = quantityType ?? throw new System.ArgumentNullException(nameof(quantityType)); QuantityInPacket = quantityInPacket; QuantityTypeInPacket = quantityTypeInPacket ?? throw new System.ArgumentNullException(nameof(quantityTypeInPacket)); ItemCategory = itemCategory; Manufacturer = manufacturer; IsInBasket = isInBasket; Quantity = quantity; }