public ActionResult Schedule(itmmSchedule a, string room, int AvailableTable, string[] Days) { Class b = new Class(); b.GroupNo = a.GroupNo; b.CourseCode = a.CourseCode; b.CourseDescription = a.CourseDesc; //b.Day = a.Day b.Day = FormatDays(Days); b.Schedule = a.Schedule; b.Instructor = a.Instructor; b.AvailableTable = AvailableTable; b.Room = room; b.LabId = getLabId(); con.AddToClasses(b); con.SaveChanges(); int lastInsertedClassId = b.ClassId; for (int i = 1; i <= AvailableTable; i++) { Table c = new Table(); c.ClassId = b.ClassId; c.TableNo = i; con.AddToTables(c); } con.SaveChanges(); return RedirectToAction("Schedule"); }
public ActionResult EditSked(int SkedId) { try { //get class schedule var a = (from y in con.Classes where y.ClassId == SkedId select y).FirstOrDefault(); itmmSchedule b = new itmmSchedule(); b.GroupNo = a.GroupNo; b.CourseCode = a.CourseCode; b.CourseDesc = a.CourseDescription; b.Days = a.Day; b.Schedule = a.Schedule; b.Instructor = a.Instructor; b.AvailableTable = Convert.ToInt32(a.AvailableTable); int labid = getLabId(); //room list exclusive per lab var x = from y in con.Laboratory_Room where y.LaboratoryId == labid orderby y.Room.RoomName select y.Room; ViewBag.RoomList = x; ViewBag.Days = new string[] { "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" }; return View(b); }catch(Exception){ return RedirectToAction("Schedule"); } }
public ActionResult EditSked(itmmSchedule a, string room, int SkedId, int AvailableTable, string[] Days) { var b = (from y in con.Classes where y.ClassId == SkedId select y).FirstOrDefault(); b.GroupNo = a.GroupNo; b.CourseCode = a.CourseCode; b.CourseDescription = a.CourseDesc; // b.Day = a.Day; b.Day = FormatDays(Days); b.Schedule = a.Schedule; b.Instructor = a.Instructor; b.Room = room; b.AvailableTable = AvailableTable; // 1. delete added tables var x = from y in con.Tables where y.ClassId == SkedId select y; foreach (var obj in x) { con.DeleteObject(obj); } // 2. adding tables again int lastInsertedClassId = b.ClassId; for (int i = 1; i <= AvailableTable; i++) { Table c = new Table(); c.ClassId = lastInsertedClassId; c.TableNo = i; con.AddToTables(c); } con.SaveChanges(); return RedirectToAction("Schedule"); }
public ActionResult EditSked(itmmSchedule a,string room ,int SkedId) { var b = (from y in con.Classes where y.ClassId == SkedId select y).FirstOrDefault(); b.GroupNo = a.GroupNo; b.CourseCode = a.CourseCode; b.CourseDescription = a.CourseDesc; b.Day = a.Day; b.Schedule = a.Schedule; b.Instructor = a.Instructor; b.Room = room; b.AvailableTable = a.AvailableTable; con.SaveChanges(); return RedirectToAction("Schedule"); }