public async Task <IActionResult> CreateInitialProfile([FromBody] CreateInitialProfileRequest profile) { try { if (!ModelState.IsValid) { return(Ok(new OperationResponse { HasSucceeded = false, IsDomainValidationErrors = true, StatusCode = ((int)ResponseStatus.BadRequest).ToString(), Message = string.Join("; ", ModelState.Values .SelectMany(x => x.Errors) .Select(x => x.ErrorMessage)) })); } ProfileDataAccess _profileAccess = new ProfileDataAccess(_iconfiguration); DatabaseResponse response = await _profileAccess.CreateInitialProfile(profile); if (response.ResponseCode == (int)DbReturnValue.CreateSuccess) { DatabaseResponse userResponse = await _profileAccess.GetUserProfileById(((UserMaster)response.Results).Id); if (userResponse.ResponseCode == (int)DbReturnValue.RecordExists) { return(Ok(new OperationResponse { HasSucceeded = true, IsDomainValidationErrors = false, Message = EnumExtensions.GetDescription(DbReturnValue.CreateSuccess), ReturnedObject = userResponse.Results })); } else { return(Ok(new OperationResponse { HasSucceeded = true, IsDomainValidationErrors = false, Message = EnumExtensions.GetDescription(DbReturnValue.CreationFailed) })); } } else if (response.ResponseCode == (int)DbReturnValue.EmailExists) { Log.Error(EnumExtensions.GetDescription(DbReturnValue.EmailExists)); return(Ok(new OperationResponse { HasSucceeded = false, IsDomainValidationErrors = false, Message = EnumExtensions.GetDescription(DbReturnValue.EmailExists), ReturnedObject = response.Results })); } else { Log.Error(EnumExtensions.GetDescription(DbReturnValue.CreationFailed)); return(Ok(new OperationResponse { HasSucceeded = false, IsDomainValidationErrors = false, Message = EnumExtensions.GetDescription(DbReturnValue.CreationFailed), // ReturnedObject = response.Results })); } } catch (Exception ex) { Log.Error(new ExceptionHelper().GetLogString(ex, ErrorLevel.Critical)); return(Ok(new OperationResponse { HasSucceeded = false, Message = StatusMessages.ServerError, StatusCode = ((int)ResponseStatus.ServerError).ToString(), IsDomainValidationErrors = false })); } }