public ActionResult Delete(int?mailboxId, int?id) { DBEntities e = COREobject.i.Context; IncomingEmailRule row = e.IncomingEmail.Single(t => t.Id == mailboxId).IncomingEmailRule.Single(r => r.Id == id); if (row == null) { throw new Exception("Do?lo k neoèekávané chybì"); } e.IncomingEmailRule.Remove(row); e.SaveChanges(); return(RedirectToRoute("HermesIncomingRule", new { @action = "Index", @mailboxId = mailboxId })); }
private static bool EvaluateRule(IncomingEmailRule rule, MailMessage mail) { bool result = true; JToken conditionSets = JToken.Parse(rule.Rule); foreach (JToken set in conditionSets) { if ((string)set["SetRelation"] == "AND") { result = result && MatchConditionSet(set, mail); } else if ((string)set["SetRelation"] == "OR") { result = result || MatchConditionSet(set, mail); } } return(result); }
public ActionResult Edit(int?mailboxId, int?id) { DBEntities e = COREobject.i.Context; IncomingEmailRule rule = e.IncomingEmail.Single(m => m.Id == mailboxId).IncomingEmailRule.Single(r => r.Id == id); List <SelectListItem> appList = new List <SelectListItem>(); foreach (Application a in e.Applications.OrderBy(a => a.Name)) { appList.Add(new SelectListItem() { Value = a.Id.ToString(), Text = a.Name, Selected = rule.ApplicationId == a.Id }); } ViewData["mailboxId"] = mailboxId; ViewData["ApplicationList"] = appList; return(View("~/Views/Hermes/IncomingRule/Form.cshtml", rule)); }
public ActionResult Save(IncomingEmailRule model, int?mailboxId, int?id) { if (mailboxId == null) { throw new Exception("Do?lo k neoèekávané chybì"); } DBEntities e = COREobject.i.Context; if (ModelState.IsValid) { // Záznam ji. existuje - pouze upravujeme if (!model.Id.Equals(null)) { IncomingEmailRule row = e.IncomingEmailRule.Single(m => m.Id == model.Id); row.ApplicationId = model.ApplicationId; row.IncomingEmailId = (int)mailboxId; row.BlockName = model.BlockName; row.WorkflowName = model.WorkflowName; row.Rule = model.Rule; row.Name = model.Name; e.SaveChanges(); } else { model.IncomingEmailId = (int)mailboxId; e.IncomingEmailRule.Add(model); e.SaveChanges(); } return(RedirectToRoute("HermesIncomingRule", new { @action = "Index", @mailboxId = mailboxId })); } else { return(View("~/Views/Hermes/IncomingRule/Form.cshtml", model)); } }