public async Task <ActionResult <MailTemplate_MailTemplateDTO> > Create([FromBody] MailTemplate_MailTemplateDTO MailTemplate_MailTemplateDTO) { if (UnAuthorization) { return(Forbid()); } if (!ModelState.IsValid) { throw new BindException(ModelState); } if (!await HasPermission(MailTemplate_MailTemplateDTO.Id)) { return(Forbid()); } MailTemplate MailTemplate = ConvertDTOToEntity(MailTemplate_MailTemplateDTO); MailTemplate = await MailTemplateService.Create(MailTemplate); MailTemplate_MailTemplateDTO = new MailTemplate_MailTemplateDTO(MailTemplate); if (MailTemplate.IsValidated) { return(MailTemplate_MailTemplateDTO); } else { return(BadRequest(MailTemplate_MailTemplateDTO)); } }
private MailTemplate ConvertDTOToEntity(MailTemplate_MailTemplateDTO MailTemplate_MailTemplateDTO) { MailTemplate MailTemplate = new MailTemplate(); MailTemplate.Id = MailTemplate_MailTemplateDTO.Id; MailTemplate.Code = MailTemplate_MailTemplateDTO.Code; MailTemplate.Name = MailTemplate_MailTemplateDTO.Name; MailTemplate.Content = MailTemplate_MailTemplateDTO.Content; MailTemplate.StatusId = MailTemplate_MailTemplateDTO.StatusId; MailTemplate.Status = MailTemplate_MailTemplateDTO.Status == null ? null : new Status { Id = MailTemplate_MailTemplateDTO.Status.Id, Code = MailTemplate_MailTemplateDTO.Status.Code, Name = MailTemplate_MailTemplateDTO.Status.Name, }; MailTemplate.BaseLanguage = CurrentContext.Language; return(MailTemplate); }
public async Task <ActionResult <MailTemplate_MailTemplateDTO> > Get([FromBody] MailTemplate_MailTemplateDTO MailTemplate_MailTemplateDTO) { if (UnAuthorization) { return(Forbid()); } if (!ModelState.IsValid) { throw new BindException(ModelState); } if (!await HasPermission(MailTemplate_MailTemplateDTO.Id)) { return(Forbid()); } MailTemplate MailTemplate = await MailTemplateService.Get(MailTemplate_MailTemplateDTO.Id); return(new MailTemplate_MailTemplateDTO(MailTemplate)); }