public StaffFilterClauseModel GetDefaultStaffClause() { StaffFilterClauseModel m = new StaffFilterClauseModel(DynamicStaffClause.GetDefault(FilterId)); m.FormArea = "My"; m.FormController = "Contacts"; m.FormAction = "AddStaffClause"; m.SubmitText = "Add Clause"; return m; }
public ActionResult AddStaffClause(StaffFilterClauseModel m) { DynamicStaffFilter f = new DynamicStaffFilter(m.FilterId); f.CreateClause(m.ToFilterClause()); return RedirectToAction("StaffMembership", new { id = m.FilterId }); }
public ActionResult AddStaffClause(StaffFilterClauseModel m) { if (!m.BuildingInclude & !m.EmployeeTypeInclude & !m.JobTitleInclude & !m.StatusInclude & !m.StaffIdInclude & !m.LastNameInclude) ModelState.AddModelError("", "Please include at least one field in the filter"); MemberFilter f = null; try { f = DbContext.MemberFilters.First(x => x.FilterId.Equals(m.FilterId)); } catch { ModelState.AddModelError("", "Invalid filter id"); } int count = DbContext.StaffFilterClauses.Where(x => x.FilterId.Equals(m.FilterId)).Count(); bool hasErrors = ViewData.ModelState.Values.Any(x => x.Errors.Count > 1); List<ModelState> errors = ViewData.ModelState.Values.Where(x => x.Errors.Count() > 0).ToList(); if (ModelState.IsValid) { try { StaffFilterClause c = new StaffFilterClause(); AnvilEntity e = new AnvilEntity(m); e.CopyTo(c); c.StaffFilterClauseId = Guid.NewGuid(); c.SortIndex = count; DbContext.StaffFilterClauses.Add(c); DbContext.SaveChanges(); } catch (Exception ex) { return View("~/Views/Shared/Error.cshtml", new AnvilExceptionModel(ex, "Create Staff Clause", "My", "Contacts", "EditStaffFilter")); } } else { AnvilExceptionCollector ec = new AnvilExceptionCollector("The staff filter clause could not be validated"); foreach (ModelState ms in errors) { foreach (var x in ms.Errors) { ec.Add(x.ErrorMessage); } } AnvilExceptionModel em = new AnvilExceptionModel(ec.ToException(), "Create Staff Filter Clause", null, null, null); MemberFilterModel fm = new MemberFilterModel(f); fm.Exception = em; return View("EditFilter", fm); } return RedirectToAction("EditFilter", new { id = m.FilterId }); }
public StaffFilterClauseModel GetStaffFilterClause(Guid id) { if (CurrentTemplate != null) { StaffFilterClauseModel m = new StaffFilterClauseModel(DynamicStaffClause.GetDefault(id)) { FormAction = "AddStaffClause", FormController = "LdapGroupTemplate", FormArea = "LcpsLdap", SubmitText = "Add Clause" }; return m; } else throw new Exception("Could not get student filter. The OU has not been set"); }
public ActionResult Search(StaffFilterClauseModel m) { this.StaffClause = m; return RedirectToAction("Index"); }