Ejemplo n.º 1
0
        public ProductDTO CreateProduct(ProductDTO productDTO)
        {
            if(productDTO == null)
                throw new ArgumentNullException("product", "Product cannot be null");

            var entity = Mapper.Map<Product>(productDTO);

            var created = ProductRepository.Create(entity);

            return Mapper.Map<ProductDTO>(created);
        }
Ejemplo n.º 2
0
        public IHttpActionResult CreateProduct(ProductDTO product)
        {
            if (!ModelState.IsValid)
                return BadRequest("Invalid data");

            var productResult = Business.CreateProduct(product);

            var result = new ServiceResult<ProductDTO>
            {
                StatusCode = HttpStatusCode.OK,
                Data = productResult,
                Success = true
            };
            return Ok(result);
        }