Beispiel #1
0
        public ActionResult BookGroup(CreateBooking booking)
        {
            if (!CapacityCheck(booking))
            {
                var warningMessage = "Unable to create the group booking. " + Resource(booking).Name + " has a capacity of " +
                                     Resource(booking).Capacity + ", this booking requires a capacity of " + BookingCapacity(booking);

                return(RedirectToAction("Index", new { warningMessage = warningMessage }));
            }
            try
            {
                var userId = Session["UserId"].ToString();
                var user   = userService.GetUser(new Guid(userId));

                service.AddGroupBooking(
                    booking.GroupBooking.Date,
                    booking.GroupBooking.SelectedAttendees.ToList(),
                    booking.GroupBooking.SelectedTeams.ToList(),
                    booking.GroupBooking.StartTime,
                    booking.GroupBooking.EndTime,
                    booking.Resource,
                    user.UserId);

                return(RedirectToAction("Index", new { successMessage = "Group booking successfully added!" }));
            }
            catch (Exception e)
            {
                ModelState.AddModelError("", e);
                return(View(booking));
            }
        }