Ejemplo n.º 1
0
        public bool CreateBrand(Brand brand)
        {
            var result = _unitOfWork.Brands.CreateBrand(brand);

            _unitOfWork.Complete();
            return(result);
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> CreateProduct([FromBody] Product product)
        {
            if (product.Name.Equals(string.Empty) || product.Price == 0)
            {
                return(BadRequest("Incorrect input"));
            }

            var entity = new Product
            {
                Id    = _unitOfWork.ProductRepository.GetLast() == null ? 1 : _unitOfWork.ProductRepository.GetLast().Id + 1,
                Name  = product.Name,
                Price = product.Price
            };

            _unitOfWork.ProductRepository.Add(entity);

            await _unitOfWork.Complete();

            return(Ok(entity));
        }