Example #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);
     }
 }
Example #2
0
 override public bool Update(User user)
 {
     try
     {
         user.Password = "******";
         _context.Entry(user).State = EntityState.Modified;
         _context.Entry(user).Property(x => x.Password).IsModified = false;
         _context.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
Example #3
0
 public override bool Update(Student student)
 {
     try
     {
         student.Password = "******";
         _context.Entry(student).State = EntityState.Modified;
         _context.Entry(student).Property(x => x.Password).IsModified = false;
         _context.Entry(student).Property(x => x.Cgpa).IsModified     = false;
         _context.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
Example #4
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);
            }
        }