Пример #1
0
        public async Task <IActionResult> UpdateAdviser([FromBody] AdviserMessageExtended request)
        {
            var response = await _adviserService.UpdateAdviser(request);

            if (response == null ||
                !response.IsSuccess ||
                (response.ValidationMessages != null && response.ValidationMessages.Any()))
            {
                return(BadRequest(response));
            }

            return(Ok(response));
        }
Пример #2
0
        /// <summary>
        /// Updates the adviser.
        /// </summary>
        /// <param name="adviser">The adviser.</param>
        /// <returns></returns>
        public async Task <ResponseMessage> UpdateAdviser(AdviserMessageExtended adviser)
        {
            var responseMassage = InitilizeResponseMessage();

            var adviserToUpdate = new Adviser
            {
                Id          = new Guid(adviser.AdviserId),
                UserDetails = new AdviserUserDetails
                {
                    Name                  = adviser.Name,
                    MiddleName            = adviser.MiddleName ?? null,
                    LastName              = adviser.LastName,
                    Dob                   = SetDob(adviser.Dob, ref responseMassage),
                    CompanyName           = adviser.CompanyName,
                    NationInsuranceNumber = adviser.NationInsuranceNumber
                },
                TotalAssetsUnderManagement = adviser.TotalAssetsUnderManagement,
                TotalFeesAndCharges        = adviser.TotalFeesAndCharges,
                IsActive = adviser.IsActive
            };

            if (!responseMassage.IsSuccess)
            {
                return(responseMassage);
            }

            _adviserRepository.Update(adviserToUpdate);
            var result = await _uow.Commit();

            if (!result)
            {
                SetValidationMessage(responseMassage, ResponseMessageTransactionFailed);
            }

            return(responseMassage);
        }