public async Task <ActionResult <SmsTemplate_SmsTemplateDTO> > Create([FromBody] SmsTemplate_SmsTemplateDTO SmsTemplate_SmsTemplateDTO)
        {
            if (!ModelState.IsValid)
            {
                throw new BindException(ModelState);
            }

            if (!await HasPermission(SmsTemplate_SmsTemplateDTO.Id))
            {
                return(Forbid());
            }

            SmsTemplate SmsTemplate = ConvertDTOToEntity(SmsTemplate_SmsTemplateDTO);

            SmsTemplate = await SmsTemplateService.Create(SmsTemplate);

            SmsTemplate_SmsTemplateDTO = new SmsTemplate_SmsTemplateDTO(SmsTemplate);
            if (SmsTemplate.IsValidated)
            {
                return(SmsTemplate_SmsTemplateDTO);
            }
            else
            {
                return(BadRequest(SmsTemplate_SmsTemplateDTO));
            }
        }
        public async Task <ActionResult <SmsTemplate_SmsTemplateDTO> > Get([FromBody] SmsTemplate_SmsTemplateDTO SmsTemplate_SmsTemplateDTO)
        {
            if (!ModelState.IsValid)
            {
                throw new BindException(ModelState);
            }

            if (!await HasPermission(SmsTemplate_SmsTemplateDTO.Id))
            {
                return(Forbid());
            }

            SmsTemplate SmsTemplate = await SmsTemplateService.Get(SmsTemplate_SmsTemplateDTO.Id);

            return(new SmsTemplate_SmsTemplateDTO(SmsTemplate));
        }
        private SmsTemplate ConvertDTOToEntity(SmsTemplate_SmsTemplateDTO SmsTemplate_SmsTemplateDTO)
        {
            SmsTemplate SmsTemplate = new SmsTemplate();

            SmsTemplate.Id       = SmsTemplate_SmsTemplateDTO.Id;
            SmsTemplate.Code     = SmsTemplate_SmsTemplateDTO.Code;
            SmsTemplate.Name     = SmsTemplate_SmsTemplateDTO.Name;
            SmsTemplate.Content  = SmsTemplate_SmsTemplateDTO.Content;
            SmsTemplate.StatusId = SmsTemplate_SmsTemplateDTO.StatusId;
            SmsTemplate.Status   = SmsTemplate_SmsTemplateDTO.Status == null ? null : new Status
            {
                Id   = SmsTemplate_SmsTemplateDTO.Status.Id,
                Code = SmsTemplate_SmsTemplateDTO.Status.Code,
                Name = SmsTemplate_SmsTemplateDTO.Status.Name,
            };
            SmsTemplate.BaseLanguage = CurrentContext.Language;
            return(SmsTemplate);
        }