public async Task <ActionResult> Delete([FromRoute] string request) { try { var result = await _service.DeleteTag(request); return(Ok(result)); } catch (BusinessLogicException ex) { return(BadRequest(new Response { Status = false, Message = ex.Message })); } catch (Exception e) { return(BadRequest(new Response { Status = false, Message = ErrorMessages.UnkownError })); } }
public ActionResult DeleteTag(int id) { var TagToDelete = _repository.GetTagById(id); _repository.DeleteTag(TagToDelete); _repository.SaveChanges(); return(NoContent()); }
public JsonResult DeleteTag(int tagId, string token) { if (!User.IsInRole("SuperAdmin") && !User.IsInRole("Admin")) { throw new Exception("Possible unauthorized access"); } if (!CheckToken(token)) { throw new Exception("Possible unauthorized access"); } _tagRepository.DeleteTag(tagId); return(Json(true, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 删除标签 /// </summary> /// <param name="tagId"></param> /// <returns></returns> public static int DeleteTag(int tagId) { Tags.RemoveAll(delegate(TagInfo tag) { return(tag.TagId == tagId); }); return(dao.DeleteTag(tagId)); }