Esempio n. 1
0
        public IActionResult SaveEmailTemplate(EmailTemplateModel model)
        {
            var emailTemplate = model.Id > 0 ? _emailTemplateService.Get(model.Id) : new EmailTemplate();

            if (emailTemplate == null)
            {
                return(NotFound());
            }

            if (emailTemplate.Id == 0 && _emailTemplateService.Count(x => x.TemplateSystemName == model.TemplateSystemName) > 0)
            {
                return(R.Fail.With("error", T("A template with this system name already exists")).Result);
            }
            _modelMapper.Map(model, emailTemplate, nameof(EmailTemplate.Id), nameof(EmailTemplate.IsSystem), nameof(EmailTemplate.TemplateSystemName));
            if (emailTemplate.Id == 0)
            {
                emailTemplate.IsSystem = false;
            }

            _emailTemplateService.InsertOrUpdate(emailTemplate);
            return(R.Success.Result);
        }