public ActionResult EditEmailTemplateSubject(string templateName, string culture) { var subject = _mailTemplateSubjectRecordRepository.Table .FirstOrDefault(s => s.TemplateName == templateName && s.Culture == culture); var viewModel = new EditEmailTemplateSubjectViewModel { TemplateName = templateName, Subject = subject == null ? "" : subject.Subject, Culture = culture }; return(PartialView("EditEmailTemplateSubject", viewModel)); }
public ActionResult EditEmailTemplateSubject(EditEmailTemplateSubjectViewModel viewModel) { var subject = _mailTemplateSubjectRecordRepository.Table .FirstOrDefault(s => s.TemplateName == viewModel.TemplateName && s.Culture == viewModel.Culture); var subjectToCreateOrUpdate = subject ?? new MailTemplateSubjectRecord(); subjectToCreateOrUpdate.TemplateName = viewModel.TemplateName; subjectToCreateOrUpdate.Culture = viewModel.Culture; subjectToCreateOrUpdate.Subject = viewModel.Subject; if (subject == null) { _mailTemplateSubjectRecordRepository.Create(subjectToCreateOrUpdate); } else { _mailTemplateSubjectRecordRepository.Update(subjectToCreateOrUpdate); } return(RedirectToAction("Index")); }