Exemple #1
0
        public async Task <ProductDetail_ProductDTO> Get([FromBody] ProductDetail_ProductDTO ProductDetail_ProductDTO)
        {
            if (!ModelState.IsValid)
            {
                throw new MessageException(ModelState);
            }

            Product Product = await ProductService.Get(ProductDetail_ProductDTO.Id);

            return(new ProductDetail_ProductDTO(Product));
        }
Exemple #2
0
        public Product ConvertDTOToEntity(ProductDetail_ProductDTO ProductDetail_ProductDTO)
        {
            Product Product = new Product();

            Product.Id                      = ProductDetail_ProductDTO.Id;
            Product.Code                    = ProductDetail_ProductDTO.Code;
            Product.Name                    = ProductDetail_ProductDTO.Name;
            Product.Description             = ProductDetail_ProductDTO.Description;
            Product.TypeId                  = ProductDetail_ProductDTO.TypeId;
            Product.StatusId                = ProductDetail_ProductDTO.StatusId;
            Product.MerchantId              = ProductDetail_ProductDTO.MerchantId;
            Product.CategoryId              = ProductDetail_ProductDTO.CategoryId;
            Product.BrandId                 = ProductDetail_ProductDTO.BrandId;
            Product.WarrantyPolicy          = ProductDetail_ProductDTO.WarrantyPolicy;
            Product.ReturnPolicy            = ProductDetail_ProductDTO.ReturnPolicy;
            Product.ExpiredDate             = ProductDetail_ProductDTO.ExpiredDate;
            Product.ConditionOfUse          = ProductDetail_ProductDTO.ConditionOfUse;
            Product.MaximumPurchaseQuantity = ProductDetail_ProductDTO.MaximumPurchaseQuantity;
            return(Product);
        }
Exemple #3
0
        public async Task <ActionResult <ProductDetail_ProductDTO> > Update([FromBody] ProductDetail_ProductDTO ProductDetail_ProductDTO)
        {
            if (!ModelState.IsValid)
            {
                throw new MessageException(ModelState);
            }

            Product Product = ConvertDTOToEntity(ProductDetail_ProductDTO);

            Product = await ProductService.Update(Product);

            ProductDetail_ProductDTO = new ProductDetail_ProductDTO(Product);
            if (Product.IsValidated)
            {
                return(ProductDetail_ProductDTO);
            }
            else
            {
                return(BadRequest(ProductDetail_ProductDTO));
            }
        }