示例#1
0
        public ActionResult CreateAdminRestaurant(AdminRestaurant adminRestaurant)
        {
            if (ModelState.IsValid)
            {
                var filename = CreateFileName(adminRestaurant.Restaurant.Name);
                var path     = Path.Combine(Server.MapPath(restaurantImagePath), filename);
                adminRestaurant.Restaurant.ImagePath = restaurantImagePath + filename;
                Image sourceimage = Image.FromStream(adminRestaurant.File.InputStream);
                sourceimage.Save(path, ImageFormat.Jpeg);
                restaurantRepository.AddRestaurant(adminRestaurant.Restaurant);
                //New DinnerSessions are created
                foreach (var day in dayRepository.GetAllDays())
                {
                    var startTime = adminRestaurant.StartTime;
                    for (var i = 0; i < adminRestaurant.Sessions; i++)
                    {
                        var dinnerSession = new DinnerSession
                        {
                            DayId          = day.Id,
                            AvailableSeats = adminRestaurant.Restaurant.Seats,
                            RestaurantId   = adminRestaurant.Restaurant.Id,
                            Duration       = adminRestaurant.Duration,
                            TableType      = "DinnerSessions"
                        };
                        if (i != 0)
                        {
                            startTime.AddHours((double)adminRestaurant.Duration);
                        }
                        dinnerSession.StartTime = startTime;
                        dinnerSessionRepository.AddDinnerSession(dinnerSession);
                    }
                }

                foreach (var id in adminRestaurant.FoodTypeIdList)
                {
                    RestaurantFoodType restaurantFoodType = new RestaurantFoodType()
                    {
                        FoodTypeId   = id,
                        RestaurantId = restaurantRepository.GetLastRestaurant()
                    };
                    restaurantFoodTypeRepository.AddRestaurantFoodType(restaurantFoodType);
                }
            }
            else
            {
                ModelState.AddModelError("Error", "One or more Fields were empty.");
            }



            var adminEventEditViewModel = (AdminEventEditViewModel)Session["adminEventEditViewModel"];

            adminEventEditViewModel.AdminRestaurant = adminRestaurant;
            Session["adminEventEditViewModel"]      = adminEventEditViewModel;

            return(RedirectToAction("AdminEventEdit"));
        }
示例#2
0
        public ListDayDetailVm GetAllDaysForList()
        {
            var days = _dayRepo.GetAllDays().ProjectTo <DayDetailVm>(_mapper.ConfigurationProvider).ToList();

            var dayList = new ListDayDetailVm()
            {
                Days  = days,
                Count = days.Count()
            };

            return(dayList);
        }
        //Hier halen we alle informatie op die nodig is voor de concert index
        private IndexViewModel CreateIndexViewModel()
        {
            IndexViewModel vm = new IndexViewModel
            {
                IndexFestivalDays = new List <IndexFestivalDay>()
            };

            foreach (Day day in dayRepository.GetAllDays().ToList())
            {
                IndexFestivalDay indexfestivalday = new IndexFestivalDay
                {
                    Concerts = new List <Concert>()
                };

                List <Concert> dayConcerts = concertRepository.GetConcertsByDay(day.Id);
                indexfestivalday.Concerts.AddRange(dayConcerts);
                indexfestivalday.Date = day.Date;
                indexfestivalday.Day  = day;
                //Hier halen we even de locatie uit de eerste dayConcert omdat ze per dag hetzelfde zijn
                indexfestivalday.Location = dayConcerts[0].Location.Name;

                vm.IndexFestivalDays.Add(indexfestivalday);
            }

            return(vm);
        }