Beispiel #1
0
 public void insertIntoStud(Stud stud)
 {
     try
     {
         studentContext context = new studentContext();
         context.Stud.Add(stud);
         context.SaveChanges();
     }
     catch (System.Exception e)
     {
         throw new Exception(e.Message);
     }
 }
Beispiel #2
0
 public void updateStudent(Stud student)
 {
     try
     {
         using (var db = new studentContext())
         {
             var std = db.Stud.First(x => x.Sid == student.Sid);
             std.Fname = student.Fname;
             db.SaveChanges();
         }
     }
     catch (System.Exception)
     {
         throw;
     }
 }
Beispiel #3
0
 public void deleteStudent(Stud student)
 {
     try
     {
         using (var db = new studentContext())
         {
             var std = db.Stud.First(x => x.Sid == student.Sid);
             db.Stud.Remove(std);
             db.SaveChanges();
         }
     }
     catch (System.Exception)
     {
         throw;
     }
 }
Beispiel #4
0
 public void getAllStudents()
 {
     try
     {
         using (var db = new studentContext())
         {
             foreach (var item in db.Stud)
             {
                 System.Console.WriteLine(item.Sid + item.Fname + item.Dob);
             }
         }
     }
     catch (System.Exception e)
     {
         throw new Exception(e.Message);
     }
 }
Beispiel #5
0
        public List <Stud> getAllStudentsList()
        {
            List <Stud> studentE;

            try
            {
                using (var db = new studentContext())
                {
                    IQueryable <Stud> en = from obj in db.Stud
                                           select obj;
                    studentE = en.ToList();
                }
            }
            catch (System.Exception e)
            {
                throw e;
            }
            return(studentE);
        }
Beispiel #6
0
 public StudentController(studentContext context)
 {
     _studentContext = context;
 }
 public StudentMastersAPI(studentContext context)
 {
     _context = context;
 }