Example #1
0
        public async Task <IActionResult> Delete(long id)
        {
            var price = await _priceRepo.GetAsync(id);

            if (price == null)
            {
                return(NotFound(Resources.Items.ItemResource.PriceNotFound));
            }

            var affectedRows = await _priceRepo.DeleteAsync(price);

            if (affectedRows == -1)
            {
                return(BadRequest(Resources.Items.ItemResource.CanNotDeletePrice));
            }
            if (affectedRows > 0)
            {
                var viewModel = AutoMapper.Mapper.Map <PriceViewModel>(price);
                return(Ok(viewModel));
            }
            return(BadRequest());
        }