Пример #1
0
        private SendSmsResultViewModel SendConfirmationCode(User user)
        {
            var model = new SendSmsResultViewModel()
            {
                Errors = new List <string>()
            };
            var code          = GenerateCode();
            var message       = "Ваш код подтверждения " + code;
            var sendSmsResult = _smsService.CreateAndSendSms(message, user);

            model.SmsMessageSendId = sendSmsResult.SendSmsId;
            if (sendSmsResult.RequestResult.ErrorCode != null)
            {
                model.Errors.Add(sendSmsResult.RequestResult.ErrorText);
                return(model);
            }

            RegisterConfirmationCode(user.Id, code);

            var checkStatusResult = _smsService.CheckAndUpdateSmsStatus((int)sendSmsResult.SendSmsId, user.PhoneNumber);

            if (checkStatusResult.RequestResult.ErrorCode != null)
            {
                model.Errors.Add(checkStatusResult.RequestResult.ErrorText);
            }
            model.SmsStatus  = checkStatusResult.Status;
            model.StatusInfo = checkStatusResult.StatusText;
            model.UserId     = user.Id;
            model.CodeTmp    = code; // TODO: УБРАТЬ ЭТО !!!
            return(model);
        }