コード例 #1
0
        public ActionResult AddAttendee(Guid?bookingId, Guid?userId)
        {
            try
            {
                var booking = service.GetBooking(bookingId);

                if ((booking.ConfirmedAttendees.Count() + booking.UnconfirmedAttendees.Count()) >= booking.Resource.Capacity)
                {
                    var warningMessage = "Unable to add attendee to booking. " + booking.Resource.Name + " has a capacity of " +
                                         booking.Resource.Capacity + ". Confirmed attendees: " + booking.ConfirmedAttendees.Count() + " Unconfirmed attendees: " + booking.UnconfirmedAttendees.Count();

                    return(RedirectToAction("Index", new { warningMessage = warningMessage }));
                }

                service.AddAttendeeToGroupBooking(bookingId, userId);

                return(RedirectToAction("Index", new { successMessage = "Attendee successfully added to group booking!" }));
            }
            catch
            {
                return(RedirectToAction("Index", new { warningMessage = "Opps...Something went wrong, please try again or contact the tech team." }));
            }
        }