public ActionResult Delete(int id) { using (var context = new InnostarModelsContext()) { var repository = new MessageTemplateRepository(context); var template = repository._Get(e => e.Id == id).FirstOrDefault(); if (!template.Blocked) { repository._Delete(template); repository._Save(); } } return(RedirectToAction("Index")); }
public string _TextTemplate(int id) { using (var context = new InnostarModelsContext()) { var repository = new MessageTemplateRepository(context); var template = repository._Get(e => e.Id == id).ToList(); if (template.Any()) { return(template.FirstOrDefault().Message); } else { return(string.Empty); } } }
public ActionResult Edit(MessageTemplateViewModel model) { using (var context = new InnostarModelsContext()) { var repository = new MessageTemplateRepository(context); var template = repository._Get(e => e.Id == model.Id).FirstOrDefault(); template.Message = model.Text; if (!model.Blocked) { template.Title = model.Title; } repository._Update(template); repository._Save(); } return(RedirectToAction("Index")); }