public async Task <IActionResult> Post(SmsDto smsDto)
        {
            var sms = smsDto.ToLogicModel();
            var smsProcessResult = await _smsGatewayService.SaveReportAsync(sms);

            if (!smsProcessResult.IsRequestValid)
            {
                return(BadRequest(smsProcessResult.RequestErrors));
            }

            var response = new SmsResponseDto
            {
                PhoneNumber     = smsProcessResult.PhoneNumber,
                FeedbackMessage = smsProcessResult.FeedbackMessage
            };

            return(Ok(response));
        }
コード例 #2
0
        public static Sms ToLogicModel(this SmsDto smsDto)
        {
            if (smsDto == null)
            {
                return(null);
            }

            return(new Sms
            {
                Sender = smsDto.Sender,
                Timestamp = smsDto.Timestamp,
                Text = smsDto.Text,
                MsgId = smsDto.MsgId,
                ApiKey = smsDto.ApiKey,
                Timezone = smsDto.Timezone,
                TextBinary = smsDto.TextBinary,
                ModemNo = smsDto.ModemNo,
                OidIdentifier = smsDto.OidIdentifier,
                Latitude = smsDto.Latitude,
                Longitude = smsDto.Longitude
            });
        }