Ejemplo n.º 1
0
 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);
     }
 }
Ejemplo n.º 2
0
 public IEnumerable <Course> GetAllByDepartment(int deptId)
 {
     return(_context.Set <Course>().Where(x => x.DepartmentId == deptId));
 }
Ejemplo n.º 3
0
 public Student GetByFormattedId(String formattedId)
 {
     return(_context.Set <Student>().SingleOrDefault(x => x.FormattedId == formattedId));
 }
Ejemplo n.º 4
0
 public User GetByUserName(string userName)
 {
     return(_context.Set <User>().SingleOrDefault(x => x.UserName == userName));
 }
Ejemplo n.º 5
0
        //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);
            }
        }