Exemple #1
0
        public IHttpActionResult Get([FromUri] EmailTemplateGetModel requestModel)
        {
            if (requestModel.Count <= 0)
            {
                requestModel.Count = 15;
            }

            if (requestModel.Page <= 0)
            {
                requestModel.Page = 1;
            }

            //get the email templates
            var emailTemplates = _emailTemplateService.Get(x => !requestModel.MasterOnly || x.IsMaster, page: requestModel.Page, count: requestModel.Count).ToList();
            var model          = emailTemplates.Select(x => x.ToEntityModel());

            return(RespondSuccess(new {
                EmailTemplates = model
            }));
        }
Exemple #2
0
        public IActionResult GetById(int id)
        {
            var emailMessage = _emailTemplateService.Get(id);

            if (emailMessage == null)
            {
                return(RespondFailure());
            }
            var model = emailMessage;//.ToModel();

            return(RespondSuccess(model));
        }
        public IActionResult EmailTemplateEditor(int emailTemplateId)
        {
            var emailTemplate = emailTemplateId > 0 ? _emailTemplateService.Get(emailTemplateId) : new EmailTemplate();

            if (emailTemplate == null)
            {
                return(NotFound());
            }
            var model = _modelMapper.Map <EmailTemplateModel>(emailTemplate);

            if (emailTemplate.ParentEmailTemplate != null)
            {
                model.ParentEmailTemplate = _modelMapper.Map <EmailTemplateModel>(emailTemplate.ParentEmailTemplate);
            }

            model.EmailAccount = _modelMapper.Map <EmailAccountModel>(emailTemplate.EmailAccount);
            //available email accounts
            var emailAccounts          = _emailAccountService.Get(x => true).OrderBy(x => x.Email).ToList();
            var availableEmailAccounts = SelectListHelper.GetSelectItemList(emailAccounts, x => x.Id, x => x.Email);

            //available master templates
            var masterTemplates          = _emailTemplateService.Get(x => x.IsMaster).OrderBy(x => x.TemplateName).ToList();
            var availableMasterTemplates =
                SelectListHelper.GetSelectItemList(masterTemplates, x => x.Id, x => x.TemplateName);

            var isAdminEmailRequired = emailTemplate.TemplateSystemName != null &&
                                       ((emailTemplate.TemplateSystemName.EndsWith(EmailTemplateNames.AdminSuffix) && emailTemplate.IsSystem) ||
                                        (emailTemplate.TemplateSystemName.EndsWith(EmailTemplateNames.AdminSuffix)));
            //available tokens
            var tokens = _emailTemplateService.GetTemplateTokens(emailTemplate.TemplateSystemName).OrderBy(x => x);

            return(R.Success.With("emailTemplate", model)
                   .With("availableEmailAccounts", availableEmailAccounts)
                   .With("availableMasterTemplates", availableMasterTemplates)
                   .With("availableTokens", tokens)
                   .With("adminEmailRequired", isAdminEmailRequired)
                   .Result);
        }
 public EmailTemplateItem Get(long id)
 {
     return(_emailTemplateService.Get(id));
 }