public async Task <IActionResult> CreateAdviser( [FromBody] AdviserMessage request) { var response = await _adviserService.CreateAdviser(request); if (response == null || !response.IsSuccess || (response.ValidationMessages != null && response.ValidationMessages.Any())) { return(BadRequest(response)); } return(Ok(response)); }
/// <summary> /// Creates the adviser. /// </summary> /// <param name="newAdviser">The new adviser.</param> /// <returns></returns> public async Task <ResponseMessage> CreateAdviser(AdviserMessage newAdviser) { var responseMassage = InitilizeResponseMessage(); var adviser = new Adviser { Id = Guid.NewGuid(), UserDetails = new AdviserUserDetails { Name = newAdviser.Name, MiddleName = newAdviser.MiddleName ?? null, LastName = newAdviser.LastName, Dob = SetDob(newAdviser.Dob, ref responseMassage), CompanyName = newAdviser.CompanyName, NationInsuranceNumber = newAdviser.NationInsuranceNumber }, TotalAssetsUnderManagement = newAdviser.TotalAssetsUnderManagement, TotalFeesAndCharges = newAdviser.TotalFeesAndCharges, IsActive = newAdviser.IsActive }; if (!responseMassage.IsSuccess) { return(responseMassage); } _adviserRepository.Add(adviser); var result = await _uow.Commit(); if (!result) { SetValidationMessage(responseMassage, ResponseMessageTransactionFailed); } return(responseMassage); }