Ejemplo n.º 1
0
        public async Task <IHttpActionResult> PostSectionTime(SectionTime sectionTime)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.SectionTimes.Add(sectionTime);

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (SectionTimeExists(sectionTime.SectionTimeId))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = sectionTime.SectionTimeId }, sectionTime));
        }
Ejemplo n.º 2
0
        public async Task <IHttpActionResult> PutSectionTime(int id, SectionTime sectionTime)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != sectionTime.SectionTimeId)
            {
                return(BadRequest());
            }

            db.Entry(sectionTime).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SectionTimeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Ejemplo n.º 3
0
        // GET: Home
        //public ActionResult profile()
        //{
        //    //AspNetUser  Aspuser =new
        //    //    (from c in db.AspNetUsers
        //    //            where c.Id == User.Identity.GetUserId()
        //    //            select c).ToList();
        //    return View();
        //}

        public ActionResult About()
        {
            ViewBag.Message = "The generation done successfully";
            CollegeDatabaseEntities10 _db = new CollegeDatabaseEntities10();

            var del = (from x in db.LectureTimes
                       select x);

            db.LectureTimes.RemoveRange(del);

            var dell = (from x in db.SectionTimes
                        select x);

            db.SectionTimes.RemoveRange(dell);
            // var res = functions.Generatelecandsec()
            List <GroupModel> GrpList = new List <GroupModel>();
            functions         func    = new functions();
            var res          = func.Generate_lect(ref GrpList);
            var assin        = func.generatesecs(GrpList);
            var lecTimeTable = new LectureTime();

            foreach (var item in res)
            {
                var crs_id = _db.Courses.Where(x => x.Name == item.CourseName).Select(x => x.ID).Single();
                lecTimeTable = new LectureTime()
                {
                    Course_id = crs_id, Room_id = item.RoomId, DayOfWeek = item.Day, Grp_id = item.GrpId, StartHour = item.StartHour
                };
                _db.LectureTimes.Add(lecTimeTable);
                _db.SaveChanges();
                Console.WriteLine("{0} : {1} : {2}", item.CourseName, item.StartHour, item.Day.ToString());
            }
            foreach (var item in assin)
            {
                if (item.RoomId != -1)

                {
                    SectionTime x = new SectionTime();
                    x.Course_id  = item.CourseId;
                    x.Section_id = item.SectionId;
                    x.Room_id    = item.RoomId;
                    x.DayOfWeek  = item.Day;
                    x.StartHour  = item.Start;
                    x.isLab      = item.IsLab;
                    x.isSection  = item.IsSection;
                    // if(item.Tasids)
                    x.Ta_id = item.Tasids[0];
                    _db.SectionTimes.Add(x);
                    _db.SaveChanges();
                }
            }


            return(View());
        }
Ejemplo n.º 4
0
        public async Task <IHttpActionResult> GetSectionTime(int id)
        {
            SectionTime sectionTime = await db.SectionTimes.FindAsync(id);

            if (sectionTime == null)
            {
                return(NotFound());
            }

            return(Ok(sectionTime));
        }
Ejemplo n.º 5
0
        public async Task <IHttpActionResult> DeleteSectionTime(int id)
        {
            SectionTime sectionTime = await db.SectionTimes.FindAsync(id);

            if (sectionTime == null)
            {
                return(NotFound());
            }

            db.SectionTimes.Remove(sectionTime);
            await db.SaveChangesAsync();

            return(Ok(sectionTime));
        }
Ejemplo n.º 6
0
 PointCalcArgs GetArg(SectionTime sect)
 {
     Debug.Assert(sect.Section < times.Length);
     var p1 = points[sect.Section];
     var p2 = points[sect.Section + 1];
     var v1 = (Velocitys[sect.Section]) * Lengths[sect.Section];
     var v2 = (Velocitys[sect.Section + 1]) * Lengths[sect.Section];
     var t = sect.Time * Speed / Lengths[sect.Section];
     return new PointCalcArgs(t, p1, p2, v1, v2);
 }