Ejemplo n.º 1
0
        public ActionResult DeleteTags(string id)
        {
            Guid TagsId = Guid.Empty;

            if (Guid.TryParse(id, out TagsId))
            {
                var result = tagServices.DeleteTag(TagsId);
                if (result && Request.IsAjaxRequest())
                {
                    return(Json(true, JsonRequestBehavior.AllowGet));
                }
                else if (result)
                {
                    return(RedirectToAction("Tags"));
                }
                else if (Request.IsAjaxRequest())
                {
                    return(Json(false, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(RedirectToAction("Tags"));
                }
            }
            return(HttpNotFound());
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> DeleteConfirmed(int id)
        {
            var tag = await _tagServices.GetTag(id);

            await _tagServices.DeleteTag(id);

            return(RedirectToAction(nameof(Index)));
        }
Ejemplo n.º 3
0
        public IActionResult DeleteTag([FromBody] DeleteTagRequest request)
        {
            if (request == null)
            {
                return(BadRequest(new ErrorViewModel
                {
                    ErrorCode = "400",
                    ErrorMessage = "Please provide input information correctly."
                }));
            }

            if (request.TagId <= 0)
            {
                return(BadRequest(new ErrorViewModel
                {
                    ErrorCode = "400",
                    ErrorMessage = "Tag not found"
                }));
            }

            var tag = _tagRepository.FindById(request.TagId);

            if (tag == null)
            {
                return(BadRequest(new ErrorViewModel
                {
                    ErrorCode = "400",
                    ErrorMessage = "Tag not found"
                }));
            }

            var response = _tagServices.DeleteTag(tag);

            if (response != "OK")
            {
                return(BadRequest("Can not execute. Plz contact admin"));
            }
            return(Ok(response));
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> Delete(int id)
        {
            await _tagServices.DeleteTag(id);

            return(NoContent());
        }