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