public ActionResult AddTags(TagRegisterModel model)
 {
     if (ModelState.IsValid)
     {
         if (tagServices.AddTag(model) != Guid.Empty)
         {
             return(Redirect("Tags"));
         }
         return(HttpNotFound());
     }
     else
     {
         return(View(model));
     }
 }
示例#2
0
        public IActionResult AddTag([FromBody] AddTagRequest request)
        {
            if (request == null)
            {
                return(BadRequest(new ErrorViewModel
                {
                    ErrorCode = "400",
                    ErrorMessage = "Please provide input information correctly."
                }));
            }


            var tagQuery = _tagRepository.FindByName(request.TagName);

            if (tagQuery != null)
            {
                return(BadRequest(new ErrorViewModel
                {
                    ErrorCode = "400",
                    ErrorMessage = "Tag have been create"
                }));
            }

            var tag = new Tag()
            {
                Name = request.TagName,
                Url  = request.Url
            };

            var response = _tagServices.AddTag(tag);

            if (response != "OK")
            {
                return(BadRequest("Can not execute. Plz contact admin"));
            }
            return(Ok(response));
        }