Example #1
0
        public static List<HRStaffRecord> GetList(string query, object[] parms)
        {
            if (parms == null)
                return new List<HRStaffRecord>();

            if (parms.Count() == 0)
                return new List<HRStaffRecord>();

            try
            {
                HRStaffContext db = new HRStaffContext(Properties.Settings.Default.ConnectionString);

                List<HRStaffRecord> items = db.HRStaffRecords.Where(query, parms)
                    .OrderBy(x => x.LastName + x.FirstName + x.MiddleInitial)
                    .ToList();

                return items;
            }
            catch (Exception ex)
            {
                Anvil.v2015.v001.Domain.Exceptions.AnvilExceptionCollector ec = new Anvil.v2015.v001.Domain.Exceptions.AnvilExceptionCollector("Error getting staff members");
                ec.Add(query);
                ec.Add(ex);
                throw ec.ToException();

            }
        }
Example #2
0
        public List<HRStaffRecord> Execute()
        {
            DynamicQueryStatement dqs = ToDynamicQueryStatement();

            try
            {
                HRStaffContext context = new HRStaffContext();
                if (Parms.Count() == 0)
                    return new List<HRStaffRecord>();
                else
                    return context.HRStaffRecords
                        .Where(dqs.Query, dqs.Parms)
                        .OrderBy(x => x.LastName + x.FirstName + x.MiddleInitial)
                        .ToList();

            }
            catch (Exception ex)
            {
                AnvilExceptionCollector ec = new AnvilExceptionCollector("Could not get staff records from the database");
                ec.Add(ex);
                ec.Add(dqs.Query);
                throw ec.ToException();
            }
        }