コード例 #1
0
        public ActionResult SingleEvent(AlumniEventsModel alumniBookTickets, int EventId)
        {
            if (alumniBookTickets.EventTypeId == null && alumniBookTickets.TicketsQuantity == null && alumniBookTickets.TicketAmount == null)
            {
                TempData["ErrorMessage"] = "Please select the Tickets and click book now";
                return RedirectToAction("SingleEvent", "FacultyEvents", new { Area = "Faculty", EventId = EventId });
            }
            else
            {
                if (Session["UserId"] != null)
                {
                    Event_UserSelections eventselections = new Event_UserSelections()
                    {
                        EventId = EventId,
                        UserId = Convert.ToInt32(Session["UserId"].ToString()),
                        CreatedOn = DateTime.Now,
                        CreatedBy = Convert.ToInt32(Session["UserId"].ToString()),
                        Status = true
                    };

                    Event_UserSelections eventSelection = UserSelectionServices.Create(eventselections);
                    if (alumniBookTickets.EventTypeId.Count != null && alumniBookTickets.TicketsQuantity.Count != null && alumniBookTickets.TicketAmount.Count != null)
                    {
                        for (int i = 0; i < alumniBookTickets.EventTypeId.Count; i++)
                        {
                            for (int j = i; j < alumniBookTickets.TicketAmount.Count; j++)
                            {
                                for (int k = i; k < alumniBookTickets.TicketsQuantity.Count; k++)
                                {
                                    decimal totalAmount = ((alumniBookTickets.TicketsQuantity[i]) * (alumniBookTickets.TicketAmount[i]));
                                    Events_UserBookings bookings = new Events_UserBookings()
                                    {
                                        TicketTypeId = alumniBookTickets.EventTypeId[i],
                                        EventSelectionId = eventSelection.EventSelectionId,
                                        TotalAmount = totalAmount,
                                        TotalTickets = alumniBookTickets.TicketsQuantity[i],
                                        CreatedOn = DateTime.Now,
                                        CreatedBy = Convert.ToInt32(Session["UserId"].ToString()),
                                        Status = true

                                    };

                                    UserselectionBookingServices.Create(bookings);

                                    break;
                                }
                                break;
                            }
                        }
                        return RedirectToAction("BookEvent", "FacultyEvents", new { area = "Faculty", id = eventselections.EventSelectionId });
                    }
                }
            }
            return RedirectToAction(LoginPages.Login, LoginPages.Account, new { area = "" });
        }
コード例 #2
0
 public ActionResult SingleEvent(int? EventId)
 {
     if (Session["UserId"] != null)
     {
         AlumniEventsModel eventModel = new AlumniEventsModel()
         {
             EventId = EventId.Value
         };
         if (EventId != null) ViewBag.EventsOnId = GenericMethods.GetUserEvents(EventId.Value);
         return View(eventModel);
     }
     return RedirectToAction(LoginPages.Login, LoginPages.Account, new { area = "" });
 }