Ejemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,IsDeleted,DeletedOn,CreatedOn,ModifiedOn")] Tag tag)
        {
            if (id != tag.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                await _tagServices.UpdateTag(tag.Id, tag.Name);

                return(RedirectToAction(nameof(Index)));
            }
            return(View(tag));
        }
Ejemplo n.º 2
0
        public IActionResult UpdateTag([FromBody] UpdateTagRequest 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"
                }));
            }

            tag.Name = request.TagName;
            tag.Url  = request.Url;

            var response = _tagServices.UpdateTag(tag);

            if (response != "OK")
            {
                return(BadRequest("Can not execute. Plz contact admin"));
            }
            return(Ok(response));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Put(int id, [FromBody] string name)
        {
            var model = await _tagServices.UpdateTag(id, name);

            return(Ok(model));
        }