public virtual bool Delete(int id) { try { Registration registration = _context.Set <Registration>().Find(id); _context.Entry(registration).State = EntityState.Deleted; _context.SaveChanges(); return(true); } catch { return(false); } }
public IEnumerable <Course> GetAllByDepartment(int deptId) { return(_context.Set <Course>().Where(x => x.DepartmentId == deptId)); }
public Student GetByFormattedId(String formattedId) { return(_context.Set <Student>().SingleOrDefault(x => x.FormattedId == formattedId)); }
public User GetByUserName(string userName) { return(_context.Set <User>().SingleOrDefault(x => x.UserName == userName)); }
//Dependancy: Registration public bool DeleteSection(int id) { try { Section section = _context.Set <Section>().Find(id); IEnumerable <Registration> registrations = _context.Set <Registration>().Where(x => x.SectionId == section.Id); foreach (Registration registration in registrations) { //Registration _context.Entry(registration).State = EntityState.Deleted; } //Section _context.Entry(section).State = EntityState.Deleted; _context.SaveChanges(); return(true); } catch { return(false); } }