Example #1
0
        public async Task <EmailOrSmsGetResponse> GetDetail(EmailOrSmsGetRequest request)
        {
            EmailOrSmsGetResponse response = new EmailOrSmsGetResponse();

            try
            {
                if (!string.IsNullOrEmpty(request.Id))
                {
                    var emailSms = await _emailSmsService.GetFromDb(request.Id);

                    if (emailSms == null)
                    {
                        response.SetFail(BaseResponse.ErrorCodeEnum.EmailNotFound);
                        return(response);
                    }
                    response.EmailSms = emailSms.ToModel();
                    foreach (var messageType in response.MessageTypes)
                    {
                        messageType.Checked = response.EmailSms.MessageType.HasFlag((EnumDefine.EmailOrSmsMessageTypeEnum)messageType.Id);
                    }
                }
            }
            catch (Exception e)
            {
                response.SetFail(e);
                _logger.LogError(e, e.Message, request);
            }
            return(response);
        }
        public async Task <IActionResult> GetDetail([FromBody] EmailOrSmsGetRequest request)
        {
            try
            {
                var response = await _emailSmsAppService.GetDetail(request);

                return(Json(response));
            }
            catch (Exception e)
            {
                _logger.LogError(e, Common.Common.GetMethodName(), request);
                throw;
            }
        }