public IActionResult DeleteBrand(int brandId) { if (brandRepository.DeleteBrand(brandId)) { return(Ok(true)); } return(Ok(false)); }
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 + "\" }"); } }
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); }
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")); } }
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 })); }
public Brand DeleteBrand(int id) { return(_brandRepository.DeleteBrand(id)); }
public void DeleteBrand(Brand brand) { _brandRepository.DeleteBrand(brand); }
public async Task DeleteBrand(int id) { await _brand.DeleteBrand(id); }
public async Task DeleteBrand(int brandId) { await _brandRepo.DeleteBrand(brandId); }