public GroupTemplateViewModel(LcpsDbContext context) { _dbContext = context; LcpsAdsDomain dom = LcpsAdsDomain.Default; string d = dom.Name; }
public void Backup(string fileName) { LcpsDbContext db = new LcpsDbContext(); Buildings = db.Buildings.ToList(); EmployeeTypes = db.EmployeeTypes.ToList(); JobTitles = db.JobTitles.ToList(); Staff = db.StaffMembers.ToList(); StaffPositions = db.StaffPositions.ToList(); InstructionalLevels = db.InstructionalLevels.ToList(); Students = db.Students.ToList(); XmlSerializer xml = new XmlSerializer(this.GetType()); MemoryStream ms = new MemoryStream(); xml.Serialize(ms, this); HttpContext.Current.Response.Clear(); HttpContext.Current.Response.ContentType = "application/force-download"; HttpContext.Current.Response.AddHeader("content-disposition", "attachment; " + fileName); HttpContext.Current.Response.BinaryWrite(ms.ToArray()); HttpContext.Current.Response.End(); }
public static List<SelectListItem> GetBuildings() { List<SelectListItem> items = new List<SelectListItem>(); try { LcpsDbContext db = new LcpsDbContext(); List<HRBuilding> bb = db.Buildings.OrderBy(x => x.Name).ToList(); SelectListItem[] ii = (from HRBuilding x in bb select new SelectListItem() { Text = x.Name, Value = x.BuildingKey.ToString() }).ToArray(); items.AddRange(ii); } catch { items.Add(new SelectListItem() { Text = "Error", Value = Guid.Empty.ToString() }); } return items; }
public HomeFolderTemplateModel(LcpsDbContext context) { _dbContext = context; LcpsAdsDomain dom = LcpsAdsDomain.Default; string d = dom.Name; }
public GroupTemplateViewModel(LcpsDbContext context, Guid id) { _dbContext = context; _currentTemplate = _dbContext.GroupTemplates.Find(id); LcpsAdsDomain dom = LcpsAdsDomain.Default; string d = dom.Name; }
public HomeFolderTemplateModel(LcpsDbContext context, Guid id) { _dbContext = context; _currentTemplate = _dbContext.HomeFolderTemplates.Find(id); LcpsAdsDomain dom = LcpsAdsDomain.Default; string d = dom.Name; }
public static IEnumerable<SelectListItem> GetBuildingList() { LcpsDbContext db = new LcpsDbContext(); List<SelectListItem> items = (from HRBuilding x in db.Buildings.OrderBy(b => b.Name) select new SelectListItem() { Text = x.Name, Value = x.BuildingKey.ToString() }).ToList(); return items; }
public static IEnumerable<SelectListItem> GetJobTitleList() { LcpsDbContext db = new LcpsDbContext(); List<SelectListItem> items = (from HRJobTitle x in db.JobTitles.OrderBy(b => b.JobTitleName) select new SelectListItem() { Text = x.JobTitleName, Value = x.JobTitleKey.ToString() }).ToList(); return items; }
public static IEnumerable<SelectListItem> GetEmployeeTypeList() { LcpsDbContext db = new LcpsDbContext(); List<SelectListItem> items = (from HREmployeeType x in db.EmployeeTypes.OrderBy(b => b.EmployeeTypeName) select new SelectListItem() { Text = x.EmployeeTypeName, Value = x.EmployeeTypeLinkId.ToString() }).ToList(); return items; }
public static string GetName(Guid id) { if (id.Equals(Guid.Empty)) return ""; else { LcpsDbContext db = new LcpsDbContext(); return db.Rooms.Find(id).RoomNumber; } }
public static string GetBuildingName(Guid id) { if (id.Equals(Guid.Empty)) return ""; else { LcpsDbContext db = new LcpsDbContext(); return db.Buildings.Find(id).Name; } }
public int GetClauseCount(Guid filterId) { LcpsDbContext db = new LcpsDbContext(); List<StaffFilterClause> cc = db.StaffFilterClauses .Where(x => x.FilterId.Equals(filterId)) .OrderBy(x => x.SortIndex) .ToList(); int count = cc.Count(); return count; }
public static void SendEmail(Guid toUserId, string subject, string body) { LcpsDbContext _dbContext = new LcpsDbContext(); ApplicationBase app = LcpsDbContext.DefaultApp; ApplicationUser u = _dbContext.Users.Find(toUserId); NetworkCredential c = new NetworkCredential(app.SMTPUserName, app.SMTPPassword); string from = LcpsDbContext.DefaultApp.SMTPUserName; string to = u.Email; SendEmail(to, from, subject, body, c); }
public void Load(Guid staffKey) { try { LcpsDbContext db = new LcpsDbContext(); StaffMember = db.StaffMembers.First(x => x.StaffKey.Equals(staffKey)); StaffPositions = db.StaffPositions.Where(x => x.StaffMemberId.Equals(staffKey)); EmailAccounts = db.EmailAccounts.Where(x => x.UserLink.Equals(staffKey)); LdapAccounts = db.LdapAccounts.Where(x => x.UserKey.Equals(staffKey)); } catch (Exception ex) { throw new Exception("could not load staff data", ex); } }
public ActionResult GetBuildings() { LcpsDbContext db = new LcpsDbContext(); List<HRBuilding> bb = db.Buildings.OrderBy(x => x.Name).ToList(); var result = (from b in bb select new { id = b.BuildingKey.ToString(), name = b.Name }).ToList(); return Json(result, JsonRequestBehavior.AllowGet); }
public ActionResult GetRooms(Guid buildingId) { LcpsDbContext db = new LcpsDbContext(); List<HRRoom> bb = db.Rooms.Where(x => x.BuildingId.Equals(buildingId)).OrderBy(x => x.RoomNumber).ToList(); var result = (from b in bb select new { id = b.RoomKey.ToString(), name = (b.PrimaryOccupant == null) ? b.RoomNumber : b.RoomNumber + " " + b.PrimaryOccupant }).ToList(); return Json(result, JsonRequestBehavior.AllowGet); }
public HRStaffPositionDefinition(string buildingId, string employeeTypeId, string jobTitleId, LcpsDbContext db) { this.Building= db.Buildings.FirstOrDefault(x => x.BuildingId == buildingId); this.EmployeeType = db.EmployeeTypes.FirstOrDefault(x => x.EmployeeTypeId == employeeTypeId); this.JobTitle = db.JobTitles.FirstOrDefault(x => x.JobTitleId == jobTitleId); if (Building == null) throw new Exception(string.Format("{0} is an invalid building Id", buildingId)); if (EmployeeType == null) throw new Exception(String.Format("{0} is an invalid employee type Id", employeeTypeId)); if (JobTitle == null) throw new Exception(string.Format("{0} is an invalid job title Id", jobTitleId)); }
public List<HRJobTitle> GetList(Guid? buildingId, Guid? employeeTypeId) { LcpsDbContext db = new LcpsDbContext(); List<HRJobTitle> items = new List<HRJobTitle>(); if(buildingId == null & employeeTypeId == null) { items = db.JobTitles.OrderBy(x => x.JobTitleName).ToList(); } if(buildingId != null & employeeTypeId == null) { items = (from HRJobTitle jt in db.JobTitles join HRStaffPosition p in db.StaffPositions on jt.JobTitleKey equals p.JobTitleKey where p.BuildingKey.Equals(buildingId.Value) orderby jt.JobTitleName select jt).ToList(); } if (buildingId == null & employeeTypeId != null) { items = (from HRJobTitle jt in db.JobTitles join HRStaffPosition p in db.StaffPositions on jt.JobTitleKey equals p.JobTitleKey where p.EmployeeTypeKey.Equals(employeeTypeId.Value) orderby jt.JobTitleName select jt).ToList(); } if (buildingId != null & employeeTypeId != null) { items = (from HRJobTitle jt in db.JobTitles join HRStaffPosition p in db.StaffPositions on jt.JobTitleKey equals p.JobTitleKey where p.EmployeeTypeKey.Equals(employeeTypeId.Value) & p.BuildingKey.Equals(buildingId.Value) orderby jt.JobTitleName select jt).ToList(); } return items; }
public static HRStaffRecord Get(Guid building, Guid employeeType, Guid jobTitle) { LcpsDbContext db = new LcpsDbContext(); HRStaffRecord item = new HRStaffRecord(null, null, db.Buildings.FirstOrDefault(x => x.BuildingKey.Equals(building)), db.EmployeeTypes.FirstOrDefault(x => x.EmployeeTypeLinkId.Equals(employeeType)), db.JobTitles.FirstOrDefault(x => x.JobTitleKey.Equals(jobTitle))); return item; }
public static List<InstructionalLevel> GetInstructionalLevels(Guid buildingId) { try { LcpsDbContext DbContext = new LcpsDbContext(); List<InstructionalLevel> lvl = (from InstructionalLevel i in DbContext.InstructionalLevels join Student s in DbContext.Students on i.InstructionalLevelKey equals s.InstructionalLevelKey where s.BuildingKey.Equals(buildingId) orderby i.InstructionalLevelId select i).Distinct().ToList(); return lvl; } catch(Exception ex) { throw new Exception("Error getting instructional levels for students", ex); } }
public static IEnumerable<SelectListItem> GetFilterList() { List<SelectListItem> items = new List<SelectListItem>(); SelectListItem noFilter = new SelectListItem() { Text = "No Filter", Value = "" }; items.Add(noFilter); LcpsDbContext db = new LcpsDbContext(); List<SelectListItem> buildings = (from HRBuilding b in db.Buildings orderby b.Name select new SelectListItem() { Text = "Building: " + b.Name, Value = "BuildingKey:" + b.BuildingKey.ToString()}).ToList(); items.AddRange(buildings); List<SelectListItem> grades = (from InstructionalLevel x in db.InstructionalLevels orderby x.InstructionalLevelName select new SelectListItem() { Text = "Grade: " + x.InstructionalLevelName, Value = "InstructionalLevelKey:" + x.InstructionalLevelKey.ToString()}).ToList(); items.AddRange(grades); List<SelectListItem> bg = (from Student stu in db.Students join bld in db.Buildings on stu.BuildingKey equals bld.BuildingKey join il in db.InstructionalLevels on stu.InstructionalLevelKey equals il.InstructionalLevelKey orderby bld.Name + il.InstructionalLevelName select new SelectListItem() { Text = "Building: " + bld.Name + " - " + il.InstructionalLevelName, Value = "BuildingKey:" + bld.BuildingKey.ToString() + ",InstructionalLevelKey:" + il.InstructionalLevelKey.ToString() } ).Distinct().ToList(); items.AddRange(bg); return items; }
public static List<HRBuilding> GetBuildings() { try { LcpsDbContext DbContext = new LcpsDbContext(); List<HRBuilding> bb = (from HRBuilding b in DbContext.Buildings join Student s in DbContext.Students on b.BuildingKey equals s.BuildingKey orderby b.Name select b).Distinct().ToList(); return bb; } catch(Exception ex) { throw new Exception("Error getting buildings for students", ex); } }
public PagedList<StudentRecord> GetStudents(Guid id, int? page) { LcpsDbContext db = new LcpsDbContext(); MemberFilter f = db.MemberFilters.Find(id); if (page == null) page = 1; else { if (page == 0) page = 1; } DynamicStudentFilter stu = new DynamicStudentFilter(id); stu.Refresh(); List<StudentRecord> ss = stu.Execute(); PagedList<StudentRecord> pl = new PagedList<StudentRecord>(ss, page.Value, 12); return pl; }
public bool TargetExists() { LcpsDbContext db = new LcpsDbContext(); HRStaffPosition p = HRStaffPosition.Load(StaffId, BuildingId, EmployeeTypeId, JobTitleId, db); int count = db.StaffPositions.Where(x => x.StaffMemberId.Equals(p.StaffMemberId) & x.BuildingKey.Equals(p.BuildingKey) & x.EmployeeTypeKey.Equals(p.EmployeeTypeKey) & x.JobTitleKey.Equals(p.JobTitleKey)).Count(); return (count > 0); }
public void Create() { try { HRBuilding b = ToBuilding(); LcpsDbContext db = new LcpsDbContext(); b.BuildingKey = Guid.NewGuid(); db.Buildings.Add(b); db.SaveChanges(); } catch (Exception ex) { throw new Exception("Could not add builing", ex); } }
public HRStaffPosition ToStaffPosition() { LcpsDbContext db = new LcpsDbContext(); HRStaffPosition p = HRStaffPosition.Load(StaffId, BuildingId, EmployeeTypeId, JobTitleId, db); p.Status = Status; p.FiscalYear = FiscalYear; return p; }
public void Update() { try { LcpsDbContext db = new LcpsDbContext(); HRStaffPosition p = HRStaffPosition.Load(StaffId, BuildingId, EmployeeTypeId, JobTitleId, db); HRStaffPosition tmp = db.StaffPositions.First(x => x.StaffMemberId.Equals(p.StaffMemberId) & x.BuildingKey.Equals(p.BuildingKey) & x.EmployeeTypeKey.Equals(p.EmployeeTypeKey) & x.JobTitleKey.Equals(p.JobTitleKey)); tmp.Status = this.Status; tmp.FiscalYear = this.FiscalYear; db.Entry(tmp).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } catch (Exception ex) { throw new Exception("Could not update position", ex); } }
public void Create() { try { HRJobTitle jt = ToJobTitle(); LcpsDbContext db = new LcpsDbContext(); jt.JobTitleKey = Guid.NewGuid(); db.JobTitles.Add(jt); db.SaveChanges(); } catch(Exception ex) { throw new Exception("Could not add job title", ex); } }
public static string GetBuildingName(Guid buildingKey) { LcpsDbContext db = new LcpsDbContext(); return db.Buildings.First(x => x.BuildingKey.Equals(buildingKey)).Name; }
public static IEnumerable<SelectListItem> GetBuildings() { LcpsDbContext db = new LcpsDbContext(); return db.Buildings.ToSelectListItems<HRBuilding>(x => x.Name, x => x.BuildingKey.ToString()); }