public async Task <IActionResult> UpdateClientProfile(Guid id, [FromBody] ClientProfileViewModel formdata) { try { if (formdata == null) { return(BadRequest(new JsonResult(new { message = "object sent from client is null." }))); } if (id == null || id == Guid.Empty) { return(BadRequest(new JsonResult(new { message = "object sent from client is null." }))); } if (id != formdata.Id) { return(BadRequest(new JsonResult(new { message = "please ensure you are updating right object" }))); } if (!ModelState.IsValid) { return(BadRequest("Invalid model object sent from client.")); } var clientProfile = _mapper.Map <ClientProfileDto>(formdata); var clientProfileId = await _clientProfileService.UpdateClientProfile(clientProfile); if (clientProfileId == Guid.Empty) { return(NotFound()); } clientProfile.Id = clientProfileId; return(CreatedAtAction(nameof(GetClientProfile), new { id = clientProfileId }, _mapper.Map <ClientProfileViewModel>(clientProfile))); } catch (Exception e) { return(StatusCode(500, new JsonResult(new { message = $"Something went wrong inside update clientProfile action: {e.Message}" }))); } }