public StaffFilterClause ToFilterClause()
 {
     AnvilEntity e = new AnvilEntity(this);
     StaffFilterClause c = new StaffFilterClause();
     e.CopyTo(c);
     return c;
 }
Example #2
0
        public void CreateClause(StaffFilterClause c)
        {
            try
            {

                if (c.StaffFilterClauseId.Equals(Guid.Empty))
                    c.StaffFilterClauseId = Guid.NewGuid();

                if (c.FilterId == Guid.Empty)
                    c.FilterId = this.FilterId;

                int count = DbContext.StudentFilterClauses.Where(x => x.FilterId.Equals(c.FilterId)).Count();

                c.SortIndex = count;
                DbContext.StaffFilterClauses.Add(c);
                DbContext.SaveChanges();

                Add(new DynamicStaffClause(c));
            }
            catch (Exception ex)
            {
                throw new Exception("Could not create staff clause", ex);
            }
        }
Example #3
0
        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(StaffFilterClause c)
 {
     AnvilEntity e = new AnvilEntity(c);
     e.CopyTo(this);
 }
Example #5
0
 public DynamicStaffClause(StaffFilterClause c)
 {
     FromStaffClause(c);
 }
Example #6
0
        public void FromStaffClause(StaffFilterClause c)
        {
            FilterId = c.FilterId;
            ClauseConjunction = c.ClauseConjunction;
            ClauseId = c.StaffFilterClauseId;

            if (c.BuildingInclude)
                Add(c.BuildingInclude, c.BuildingConjunction, fBuilding, c.BuildingOperator, c.BuildingValue);

            if (c.EmployeeTypeInclude)
                Add(c.EmployeeTypeInclude, c.EmployeeTypeConjunction, fEmployeeType, c.EmployeeTypeOperator, c.EmployeeTypeValue);

            if (c.JobTitleInclude)
                Add(c.JobTitleInclude, c.JobTitleConjunction, fJobTitle, c.JobTitleOperator, c.JobTitleValue);

            if (c.StatusInclude)
                Add(c.StatusInclude, c.StatusConjunction, fStatus, c.StatusOperator, Convert.ToInt32(c.StatusValue));

            if (c.LastNameInclude)
                Add(c.LastNameInclude, c.LastNameConjunction, fLastName, c.LastNameOperator, c.LastNameValue);

            if (c.StaffIdInclude)
                Add(c.StaffIdInclude, c.StaffIdConjunction, fStaffId, c.StaffIdOperator, c.StaffIdValue);

            if (c.FiscalYearInclude)
                Add(c.FiscalYearInclude, c.FiscalYearConjunction, fFiscalYear, c.FiscalYearOperator, c.FiscalYearValue);
        }
Example #7
0
 public static StaffFilterClause GetDefaultSearch()
 {
     StaffFilterClause c = new StaffFilterClause();
     c.ClauseConjunction = DynamicQueryConjunctions.Or;
     c.StatusConjunction = DynamicQueryConjunctions.And;
     c.StatusInclude = true;
     c.StatusOperator = DynamicQueryOperators.Equals;
     c.StatusValue = HRStaffPositionQualifier.Active;
     return c;
 }
Example #8
0
        public static StaffFilterClause GetDefault(Guid filterId)
        {
            StaffFilterClause c = new StaffFilterClause();
            c.FilterId = filterId;
            c.ClauseConjunction = DynamicQueryConjunctions.Or;
            c.BuildingConjunction = DynamicQueryConjunctions.And;
            c.EmployeeTypeConjunction = DynamicQueryConjunctions.And;
            c.JobTitleConjunction = DynamicQueryConjunctions.And;
            c.StatusConjunction = DynamicQueryConjunctions.And;
            c.StaffIdConjunction = DynamicQueryConjunctions.And;
            c.LastNameConjunction = DynamicQueryConjunctions.And;
            c.FiscalYearConjunction = DynamicQueryConjunctions.And;

            return c;
        }