Beispiel #1
0
        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));
        }
Beispiel #2
0
        /// <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);
        }