public async Task <IActionResult> Edit(int id, [FromBody] TypeDto typeDto) { if (typeDto == null) { return(BadRequest("You send a empty country")); } var typeInDb = _typeService.Exist(id).FirstOrDefault(); if (typeInDb == null) { return(BadRequest("Type doesn't exist!")); } var errorMsg = _typeService.CheckSameName(typeDto.Name); if (errorMsg != null) { return(BadRequest(errorMsg)); } var newType = _typeService.Edit(typeInDb, typeDto); var saved = await _typeService.SaveEf(); if (!saved) { return(BadRequest()); } return(Ok(_typeService.Exist(newType.Id).ProjectTo <TagDto>(_mapper.ConfigurationProvider).FirstOrDefault())); }