示例#1
0
 public ActionResult Delete(int id, FormCollection collection)
 {
     try
     {
         using (DBModel dBModel = new DBModel())
         {
             student_program student_program = dBModel.student_program.Where(x => x.id == id).FirstOrDefault();
             dBModel.student_program.Remove(student_program);
             dBModel.SaveChanges();
         }
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
示例#2
0
        public ActionResult Edit(int id, student_program student_program)
        {
            try
            {
                using (DBModel dbModel = new DBModel())
                {
                    dbModel.Entry(student_program).State = EntityState.Modified;
                    dbModel.SaveChanges();
                }
                // TODO: Add update logic here

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
示例#3
0
        public ActionResult Create(student_program student_program)
        {
            try
            {
                using (DBModel dbModel = new DBModel())
                {
                    dbModel.student_program.Add(student_program);
                    dbModel.SaveChanges();
                }
                // TODO: Add insert logic here

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }