private void UpdateLocationTimes(string[] selectedTimes, LocationTime LocationTimeToUpdate)
        {
            if (selectedTimes == null)
            {
                LocationTimeToUpdate.Times = new List <Time>();
                return;
            }

            var selectedTimesHS = new HashSet <string>(selectedTimes);
            var Location_Times  = new HashSet <int>
                                      (LocationTimeToUpdate.Times.Select(t => t.TimeID));//原有构成hashSet

            foreach (var time in db.Times)
            {
                if (selectedTimesHS.Contains(time.TimeID.ToString())) //eidt后有时间选择
                {
                    if (!Location_Times.Contains(time.TimeID))        //没有加上 有了不加
                    {
                        LocationTimeToUpdate.Times.Add(time);
                    }
                }
                else
                {
                    if (Location_Times.Contains(time.TimeID))
                    {
                        LocationTimeToUpdate.Times.Remove(time);
                    }
                }
            }
        }
        public ActionResult DeleteConfirmed(int id)
        {
            LocationTime LocationTime = db.LocationTimes.Find(id);

            db.LocationTimes.Remove(LocationTime);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public void TestLocationTimeConstructor()
        {
            Point    Location = new Point(10, 20);
            DateTime Time     = DateTime.Now;

            LocationTime locationTime = new LocationTime(Location, Time);

            Assert.AreEqual(Location, locationTime.Location);
            Assert.AreEqual(Time, locationTime.Time);
        }
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            LocationTime LocationTime = db.LocationTimes
                                        .Include(l => l.Times)
                                        .Where(l => l.LocationTimeID == id.Value)
                                        .Single();

            if (LocationTime == null)
            {
                return(HttpNotFound());
            }
            return(View(LocationTime));
        }
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            LocationTime locationTime = db.LocationTimes
                                        .Include(l => l.classroom).Include(l => l.course).Include(l => l.instructor)
                                        .Include(l => l.Times)
                                        .Where(l => l.LocationTimeID == id.Value).Single();

            if (locationTime == null)
            {
                return(HttpNotFound());
            }
            ViewBag.Times       = db.Times.ToList();
            ViewBag.ClassroomID = new SelectList(db.ClassRooms, "ClassRoomID", "Location");
            ViewBag.CourseID    = new SelectList(db.Courses, "CourseID", "Title");
            return(View(locationTime));
        }
        public async Task <ActionResult> Create([Bind(Include = "ClassRoomID,CourseID,InstructorID")] LocationTime locationTime, string[] selectedTimes)
        {
            if (selectedTimes != null)
            {
                locationTime.Times = new List <Time>();
                foreach (var s in selectedTimes)
                {
                    locationTime.Times.Add(db.Times.Find(int.Parse(s)));
                }
            }
            if (ModelState.IsValid)
            {
                db.LocationTimes.Add(locationTime);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewBag.Times       = db.Times.ToList();
            ViewBag.ClassroomID = new SelectList(db.ClassRooms, "ClassRoomID", "Location");
            ViewBag.CourseID    = new SelectList(db.Courses, "CourseID", "Title");
            return(View(locationTime));
        }
Пример #7
0
        void ReleaseDesignerOutlets()
        {
            if (BackButton != null)
            {
                BackButton.Dispose();
                BackButton = null;
            }

            if (BottomConstraint != null)
            {
                BottomConstraint.Dispose();
                BottomConstraint = null;
            }

            if (DistanceText != null)
            {
                DistanceText.Dispose();
                DistanceText = null;
            }

            if (EditSelf != null)
            {
                EditSelf.Dispose();
                EditSelf = null;
            }

            if (EditSelfBack != null)
            {
                EditSelfBack.Dispose();
                EditSelfBack = null;
            }

            if (EditSelfHeader != null)
            {
                EditSelfHeader.Dispose();
                EditSelfHeader = null;
            }

            if (EditSpacer != null)
            {
                EditSpacer.Dispose();
                EditSpacer = null;
            }

            if (HeaderBackground != null)
            {
                HeaderBackground.Dispose();
                HeaderBackground = null;
            }

            if (HideButton != null)
            {
                HideButton.Dispose();
                HideButton = null;
            }

            if (LastActiveDate != null)
            {
                LastActiveDate.Dispose();
                LastActiveDate = null;
            }

            if (LikeButton != null)
            {
                LikeButton.Dispose();
                LikeButton = null;
            }

            if (LocationTime != null)
            {
                LocationTime.Dispose();
                LocationTime = null;
            }

            if (MapBottomSeparator != null)
            {
                MapBottomSeparator.Dispose();
                MapBottomSeparator = null;
            }

            if (MapSatellite != null)
            {
                MapSatellite.Dispose();
                MapSatellite = null;
            }

            if (MapStreet != null)
            {
                MapStreet.Dispose();
                MapStreet = null;
            }

            if (MapTopSeparator != null)
            {
                MapTopSeparator.Dispose();
                MapTopSeparator = null;
            }

            if (MenuBlock != null)
            {
                MenuBlock.Dispose();
                MenuBlock = null;
            }

            if (MenuContainer != null)
            {
                MenuContainer.Dispose();
                MenuContainer = null;
            }

            if (MenuIcon != null)
            {
                MenuIcon.Dispose();
                MenuIcon = null;
            }

            if (MenuLayer != null)
            {
                MenuLayer.Dispose();
                MenuLayer = null;
            }

            if (MenuReport != null)
            {
                MenuReport.Dispose();
                MenuReport = null;
            }

            if (Name != null)
            {
                Name.Dispose();
                Name = null;
            }

            if (NavigationSpacer != null)
            {
                NavigationSpacer.Dispose();
                NavigationSpacer = null;
            }

            if (NextButton != null)
            {
                NextButton.Dispose();
                NextButton = null;
            }

            if (PercentProgress != null)
            {
                PercentProgress.Dispose();
                PercentProgress = null;
            }

            if (PreviousButton != null)
            {
                PreviousButton.Dispose();
                PreviousButton = null;
            }

            if (ProfileImageContainer != null)
            {
                ProfileImageContainer.Dispose();
                ProfileImageContainer = null;
            }

            if (ProfileImageScroll != null)
            {
                ProfileImageScroll.Dispose();
                ProfileImageScroll = null;
            }

            if (ProfileViewDescription != null)
            {
                ProfileViewDescription.Dispose();
                ProfileViewDescription = null;
            }

            if (ProfileViewMap != null)
            {
                ProfileViewMap.Dispose();
                ProfileViewMap = null;
            }

            if (ProfileViewScroll != null)
            {
                ProfileViewScroll.Dispose();
                ProfileViewScroll = null;
            }

            if (RegisterDate != null)
            {
                RegisterDate.Dispose();
                RegisterDate = null;
            }

            if (ResponseRate != null)
            {
                ResponseRate.Dispose();
                ResponseRate = null;
            }

            if (RippleImageNext != null)
            {
                RippleImageNext.Dispose();
                RippleImageNext = null;
            }

            if (RippleImagePrev != null)
            {
                RippleImagePrev.Dispose();
                RippleImagePrev = null;
            }

            if (RippleProfileView != null)
            {
                RippleProfileView.Dispose();
                RippleProfileView = null;
            }

            if (RoundBottom != null)
            {
                RoundBottom.Dispose();
                RoundBottom = null;
            }

            if (ScrollBottomConstraint != null)
            {
                ScrollBottomConstraint.Dispose();
                ScrollBottomConstraint = null;
            }

            if (SendLocation != null)
            {
                SendLocation.Dispose();
                SendLocation = null;
            }

            if (Snackbar != null)
            {
                Snackbar.Dispose();
                Snackbar = null;
            }

            if (SnackBottomConstraint != null)
            {
                SnackBottomConstraint.Dispose();
                SnackBottomConstraint = null;
            }

            if (SnackTopConstraint != null)
            {
                SnackTopConstraint.Dispose();
                SnackTopConstraint = null;
            }

            if (Username != null)
            {
                Username.Dispose();
                Username = null;
            }

            if (ViewportConstraint != null)
            {
                ViewportConstraint.Dispose();
                ViewportConstraint = null;
            }
        }