public JsonResult Update(EmailTemplateModel model) { var modelPersist = false; if (model == null) return Json(new JsonRequestResult { ResultType = JsonRequestResultType.Error, Message = Resources.Resource.GS_Email_Save_Error }, JsonRequestBehavior.AllowGet); var modelUpdate = new EmailTemplate().GetEmailTemplate(Settings.AutenticationKeyEarningSystem, model.IdEmailTemplate); if (modelUpdate != null) { if (!String.IsNullOrWhiteSpace(model.Texto)) { modelUpdate.Texto = model.Texto; } else { return Json(new JsonRequestResult { ResultType = JsonRequestResultType.Error, Message = Resources.Resource.GS_Email_Empty_Fields }, JsonRequestBehavior.AllowGet); } modelPersist = new EmailTemplate().UpdateRecord(Settings.AutenticationKeyEarningSystem, modelUpdate); } return Json(modelPersist ? new JsonRequestResult { ResultType = JsonRequestResultType.Success, Message = Resources.Resource.GS_Email_Edit_Successfull } : new JsonRequestResult { ResultType = JsonRequestResultType.Error, Message = Resources.Resource.GS_Email_Save_Error }, JsonRequestBehavior.AllowGet); }
private EmailTemplateModel GetTemplateModel(int? id) { var listTemplateType = new EmailTemplate().GetTemplateType(Settings.AutenticationKeyEarningSystem).ToList(); var tipoTemplate = listTemplateType.FirstOrDefault(x => x.IdTemplateType == id); ViewBag.ListTemplates = GetListTemplateTypeSelectedItem(listTemplateType, id ?? 0); ViewBag.SelectedType = id; var idEmailTemplate = id != null ? id.Value : 0; var emailTemplate = new EmailTemplate().GetEmailTemplate( Settings.AutenticationKeyEarningSystem, idEmailTemplate); if (emailTemplate == null) { if (tipoTemplate != null) { EmailTemplateType template; Enum.TryParse(tipoTemplate.Name, out template); return new EmailTemplateModel { IdEmailTemplate = tipoTemplate.IdTemplateType, TemplateType = template, Texto = String.Empty, Titulo = tipoTemplate.Name }; } } return emailTemplate; }
public ActionResult Send() { var template = new EmailTemplate().GetEmailTemplate(Settings.AutenticationKeyEarningSystem,EmailTemplateType.Invite.GetHashCode()); return View(new SendEmailModels { HtmlEmail = template.Texto }); }