Exemple #1
0
        public override Product Update(Product entity)
        {
            var entityInDb = RepositoryDbSet
                             .Include(aa => aa.ProductName).ThenInclude(t => t.Translations)
                             .Include(aa => aa.Length).ThenInclude(t => t.Translations)
                             .Include(aa => aa.Weight).ThenInclude(t => t.Translations)
                             .Include(aa => aa.ManuFacturerItemCode).ThenInclude(t => t.Translations)
                             .Include(aa => aa.ShopCode).ThenInclude(t => t.Translations)
                             .FirstOrDefault(x => x.Id == entity.Id);

            if (entityInDb == null)
            {
                return(entity);
            }

            entityInDb.Quantity = entity.Quantity;
            entityInDb.BuyPrice = entity.BuyPrice;
            entityInDb.PercentageAddedToBuyPrice = entity.PercentageAddedToBuyPrice;
            entityInDb.SellPrice      = entity.SellPrice;
            entityInDb.ManuFacturerId = entity.ManuFacturerId;
            entityInDb.InventoryId    = entity.InventoryId;
            entityInDb.ShopId         = entity.ShopId;
            RepositoryDbSet.Update(entityInDb);

            entityInDb.ProductName.SetTranslation(entity.ProductName);
            entityInDb.Length.SetTranslation(entity.Length);
            entityInDb.Weight.SetTranslation(entity.Weight);
            entityInDb.ManuFacturerItemCode.SetTranslation(entity.ManuFacturerItemCode);
            entityInDb.ShopCode.SetTranslation(entity.ShopCode);

            return(entity);
        }
Exemple #2
0
        public static Domain.Product MapFromDAL(DAL.App.DTO.DomainLikeDTO.Product product)
        {
            var res = product == null ? null : new Domain.Product
            {
                Id = product.Id,
                ManuFacturerItemCode      = new MultiLangString(product.ManuFacturerItemCode),
                ShopCode                  = new MultiLangString(product.ShopCode),
                ProductName               = new MultiLangString(product.ProductName),
                BuyPrice                  = product.BuyPrice,
                PercentageAddedToBuyPrice = product.PercentageAddedToBuyPrice,
                SellPrice                 = product.SellPrice,
                Quantity                  = product.Quantity,
                Weight         = new MultiLangString(product.Weight),
                Length         = new MultiLangString(product.Length),
                ManuFacturerId = product.ManuFacturerId,
                Manufacturer   = ManuFacturerMapper.MapFromDAL(product.Manufacturer),
                InventoryId    = product.InventoryId,
                Inventory      = InventoryMapper.MapFromDAL(product.Inventory),
                ShopId         = product.ShopId,
                Shop           = ShopMapper.MapFromDAL(product.Shop)
            };

            return(res);
        }