public ActionResult Delete(int id) { UserSessionObject user = Session.GetUser(); DeleteCategoryResult deleteResult = CategoryService.Delete(id, user); return(Json(deleteResult, JsonRequestBehavior.AllowGet)); }
public JsonResult Delete(int id) { var result = new DeleteCategoryResult(); result = ApiHelper <DeleteCategoryResult> .HttpGetAsync( $"{Helper.ApiUrl}api/category/delete/{id}", "DELETE" ); return(Json(new { result })); }
public DeleteCategoryResult Delete(int?categoryId, UserSessionObject user) { var result = new DeleteCategoryResult(); if (categoryId.HasValue) { if (!CheckReferencingBooks(categoryId.Value)) { CategoryData domainModel = CategoryRepository.GetDataById(categoryId.Value); if (domainModel != null) { CategoryRepository.DeleteById(categoryId.Value, user.UserId); result = new DeleteCategoryResult(categoryId.Value, domainModel.NameCategory); } } else { result.Message = "This category can't be deleted. There are books connected to this category."; } } return(result); }