public async Task <IActionResult> Edit(int id, [FromBody] TagDto tagDto) { if (ReferenceEquals(tagDto, default(TagDto))) { return(BadRequest("You send a empty country")); } var tagInDb = _tagService.Exist(id).FirstOrDefault(); if (tagInDb == null) { return(BadRequest("Tag doesn't exist!")); } var errorMsg = _tagService.CheckSameName(tagDto.Name); if (!string.IsNullOrWhiteSpace(errorMsg)) { return(BadRequest(errorMsg)); } var newTag = _tagService.Edit(tagInDb, tagDto); var saved = await _tagService.SaveEf(); if (!saved) { return(BadRequest()); } return(Ok(_tagService.Exist(newTag.Id).ProjectTo <TagDto>(_mapper.ConfigurationProvider).FirstOrDefault())); }