예제 #1
0
        public static internalDTO.DomainLikeDTO.Product MapFromExternal(externalDTO.Product product)
        {
            var res = product == null ? null : new internalDTO.DomainLikeDTO.Product()
            {
                Id                        = product.Id,
                BuyPrice                  = product.BuyPrice,
                ManuFacturerItemCode      = product.ManuFacturerItemCode,
                ShopCode                  = product.ShopCode,
                ProductName               = product.ProductName,
                PercentageAddedToBuyPrice = product.PercentageAddedToBuyPrice,
                SellPrice                 = product.SellPrice,
                Quantity                  = product.Quantity,
                Weight                    = product.Weight,
                Length                    = product.Length,
                ManuFacturerId            = product.ManuFacturerId,
                ShopId                    = product.ShopId,
                InventoryId               = product.InventoryId,

                /*ProductsWithDefectCount = product.ProductsWithDefectCount,
                 * ProductReturnsCount = product.ProductReturnsCount,
                 * ProductsSoldCount = product.ProductsSoldCount,
                 * ProductsInOrdersCount = product.ProductsInOrdersCount,*/
            };

            /*if (product?.CategoryDTOs != null)
             * {
             *  res.CategoryDTOs = product.CategoryDTOs.Select(e => CategoryMapper.MapFromExternal(e)).ToList();
             * }
             *
             * if (product?.CommentDTOs != null)
             * {
             *  res.CommentDTOs = product.CommentDTOs.Select(e => CommentMapper.MapFromExternal(e)).ToList();
             * }*/
            return(res);
        }
        public async Task <ActionResult <v1_0_DTO.Product> > PostProduct(v1_0_DTO.Product product)
        {
            product = v1_0_Mapper.ProductMapper.MapFromBLL(
                await _bll.Products.AddAsync(v1_0_Mapper.ProductMapper.MapFromExternal(product)));
            await _bll.SaveChangesAsync();

            product = v1_0_Mapper.ProductMapper.MapFromBLL(
                _bll.Products.GetUpdatesAfterUOWSaveChanges(
                    v1_0_Mapper.ProductMapper.MapFromExternal(product)));

            return(CreatedAtAction("GetProduct", new { version = HttpContext.GetRequestedApiVersion().ToString(), id = product.Id }, product));
        }
예제 #3
0
        public static internalDTO.Product MapFromExternal(externalDTO.Product product)
        {
            var res = product == null ? null : new internalDTO.Product
            {
                Id          = product.Id,
                ProductName = product.ProductName,
                ProductCode = product.ProductCode,
                Price       = product.Price
            };

            return(res);
        }
        public async Task <IActionResult> PutProduct(int id, v1_0_DTO.Product product)
        {
            if (id != product.Id)
            {
                return(BadRequest());
            }

            _bll.Products.Update(v1_0_Mapper.ProductMapper.MapFromExternal(product));
            await _bll.SaveChangesAsync();

            return(NoContent());
        }
예제 #5
0
        public static internalDTO.Product MapFromExternal(externalDTO.Product product)
        {
            var res = product == null ? null : new internalDTO.Product
            {
                Id = product.Id,
                RouteOfAdministrationId = product.RouteOfAdministrationId,
                RouteOfAdministration   = RouteOfAdministrationMapper.MapFromExternal(product.RouteOfAdministration),
                ProductClassificationId = product.ProductClassificationId,
                ProductClassification   = ProductClassificationMapper.MapFromExternal(product.ProductClassification),
                ProductNameId           = product.ProductNameId,
                ProductName             = ProductNameMapper.MapFromExternal(product.ProductName)
            };

            return(res);
        }