示例#1
0
        /// <summary>
        /// Creates the new bench.
        /// </summary>
        /// <param name="position">The position.</param>
        /// <param name="id">The identifier.</param>
        /// <param name="seatIDs">The seat i ds.</param>
        /// <returns>
        /// the viewModel of the bench.
        /// </returns>
        public BenchViewModel CreateNewObject(VRPosition position, int id, Collection<int> seatIDs)
        {
            Collection<SeatViewModel> svmList = new Collection<SeatViewModel>();

            BenchViewModel viewModel = new BenchViewModel(position, id, svmList);
            return viewModel;
        }
示例#2
0
        public ActionResult View(int?id)
        {
            if (id == null)
            {
                return(RedirectToAction("Index"));
            }

            BenchRepository benchRepo = new BenchRepository(context);
            Bench           bench     = benchRepo.GetBenchById(id.Value);

            if (bench == null)
            {
                return(RedirectToAction("Index"));
            }

            ReviewRepository reviewRepo = new ReviewRepository(context);
            List <Review>    reviews    = reviewRepo.GetReviewsByBench(id.Value);

            UserRepository userRepo = new UserRepository(context);
            List <User>    users    = userRepo.GetUsers();

            var viewModel = new BenchViewModel();

            viewModel.Id             = bench.Id;
            viewModel.Name           = bench.Name;
            viewModel.Seats          = bench.Seats;
            viewModel.Description    = bench.Description;
            viewModel.DateDiscovered = bench.DateDiscovered;
            viewModel.Latitude       = bench.Latitude;
            viewModel.Longitude      = bench.Longitude;
            viewModel.Reviews        = reviews;
            viewModel.Users          = users;

            return(View("View", viewModel));
        }
示例#3
0
        /// <summary>
        /// Updates the object.
        /// </summary>
        /// <param name="bench">The bench.</param>
        /// <param name="seatIDs">The seatIDs.</param>
        /// <returns>The same bench</returns>
        public BenchViewModel UpdateObject(BenchViewModel bench, Collection<int> seatIDs)
        {
            Collection<SeatViewModel> svmList = bench.SeatList;

            SeatFactory sf = new SeatFactory();
            foreach (int seatID in seatIDs)
            {
                if (!bench.HasSeat(seatID))
                {
                    SeatViewModel svm = sf.CreateNewObject(seatID);
                    svmList.Add(svm);
                }
            }

            bench.SetSeats();
            return bench;
        }