Example #1
0
        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");
        }
Example #2
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Tables EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToTables(Table table)
 {
     base.AddObject("Tables", table);
 }
Example #3
0
        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");
        }
Example #4
0
 /// <summary>
 /// Create a new Table object.
 /// </summary>
 /// <param name="tableId">Initial value of the TableId property.</param>
 public static Table CreateTable(global::System.Int32 tableId)
 {
     Table table = new Table();
     table.TableId = tableId;
     return table;
 }