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));
        }
Exemple #2
0
        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;
        }
Exemple #3
0
 public static QuantityTypeInPacket ToModel(this QuantityTypeInPacketContract contract)
 {
     return(new QuantityTypeInPacket(contract.Id, contract.Name, contract.QuantityLabel));
 }
        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));
        }