public IActionResult DeleteBrand(int brandId)
 {
     if (brandRepository.DeleteBrand(brandId))
     {
         return(Ok(true));
     }
     return(Ok(false));
 }
示例#2
0
        public async Task <IActionResult> DeleteConfirmed(Guid id)
        {
            var brand = await _repo.GetBrandAsync(id);

            fileManager.DeleteFile(brand.BrandImage);
            _repo.DeleteBrand(brand);
            await _repo.SaveAsync();

            return(RedirectToAction(nameof(Index)));
        }
        public DeleteBrandResponse DeleteBrand(DeleteBrandRequest deleteBrandRequest)
        {
            var brand = _brandRepository.FindBrandById(deleteBrandRequest.Id);

            _brandRepository.DeleteBrand(brand);
            var brandDto = _messageMapper.MapToBrandDto(brand);

            return(new DeleteBrandResponse
            {
                Brand = brandDto
            });
        }
 public String DeleteBrand(string brandName)
 {
     try
     {
         _repository.DeleteBrand(brandName);
         return("{ \"isSuccess\" : true }");
     }
     catch (Exception ex)
     {
         return("{ \"isSuccess\" : false," +
                "\"error_message\" : \"" + ex.Message + "\" }");
     }
 }
示例#5
0
        public async Task <IActionResult> DeleteBrand(BrandForDeleteDto brandForDelete)
        {
            var result = await repo.DeleteBrand(brandForDelete);

            if (result.IsSuccess)
            {
                return(Ok());
            }
            else
            {
                return(BadRequest(result.Exception.GetType() == typeof(ArgumentNullException)
                                    ? "No item with this id found" : "Failed to delete item"));
            }
        }
        public DeleteBrandResponse DeleteBrand(DeleteBrandRequest request)
        {
            var response = new DeleteBrandResponse();

            WithErrorHandling(() =>
            {
                var brand = _brandRepository.FindBrandById(request.Id);
                _brandRepository.DeleteBrand(brand);

                var brandDto   = brand.MapToBrandDto();
                response.Brand = brandDto;
                response.Messages.Add("Successfully deleted the brand");
                response.StatusCode = HttpStatusCode.OK;
            }, response);

            return(response);
        }
示例#7
0
        public async Task <ActionResult <Brand> > DeleteBrand(int brandId)
        {
            try
            {
                var brandToDelete = await _brandRepository.GetBrand(brandId);

                if (brandToDelete == null)
                {
                    return(NotFound($"Brand with Id = {brandId} not found"));
                }

                return(await _brandRepository.DeleteBrand(brandId));
            }
            catch (Exception)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError,
                                  "Error deleting data"));
            }
        }
示例#8
0
        public async Task <string> Delete([FromBody] string json)
        {
            var parser = new Parser(json);
            int id     = parser.AsInt("Id");

            var count = await _brandRepository.GetBrandCount(id);

            if (count == 0)
            {
                await _brandRepository.DeleteBrand(id);
            }

            var result = new
            {
                Result = count == 0,
                Count  = count
            };

            return(JsonConvert.SerializeObject(result, new JsonSerializerSettings
            {
                ReferenceLoopHandling = ReferenceLoopHandling.Ignore
            }));
        }
示例#9
0
 public Brand DeleteBrand(int id)
 {
     return(_brandRepository.DeleteBrand(id));
 }
 public void DeleteBrand(Brand brand)
 {
     _brandRepository.DeleteBrand(brand);
 }
示例#11
0
 public async Task DeleteBrand(int id)
 {
     await _brand.DeleteBrand(id);
 }
示例#12
0
 public async Task DeleteBrand(int brandId)
 {
     await _brandRepo.DeleteBrand(brandId);
 }