Example #1
0
        public ActionResult SignIn(UserViewModel userViewModel)
        {
            if (userViewModel.Email == "admin" && userViewModel.Password == "admin")
            {
                Session["UserType"]  = "Admin";
                Session["FirstName"] = "Admin";
                return(RedirectToAction("AllEvents", "Event", new { area = "" }));
            }


            EventPlusEntities db = new EventPlusEntities();
            User user            = db.Users.SingleOrDefault(u => u.Email == userViewModel.Email);

            if (user != null && user.Password == userViewModel.Password)
            {
                if (user.Organizations.Count > 0)
                {
                    Session["UserType"] = "Organizer";
                    Organization organization = db.Organizations.SingleOrDefault(x => x.UserID == user.ID);
                    Session["OrganizationID"] = organization.ID.ToString();
                }
                else
                {
                    Session["UserType"] = "Attendee";
                    Attendee attendee = db.Attendees.SingleOrDefault(x => x.UserID == user.ID);
                    Session["AttendeeID"] = attendee.ID.ToString();
                }
                Session["FirstName"] = user.First_Name;
                Session["ID"]        = user.ID.ToString();
                return(RedirectToAction("AllEvents", "Event", new { area = "" }));
            }

            return(View());
        }
Example #2
0
        public ActionResult EventDetail(int eventID)
        {
            EventPlusEntities db             = new EventPlusEntities();
            Event             singleEvent    = db.Events.SingleOrDefault(x => x.ID == eventID);
            EventViewModel    eventViewModel = new EventViewModel();


            List <Organization> list = db.Organizations.ToList();

            ViewBag.OrganizationList = new SelectList(list, "ID", "Name");

            eventViewModel.ID                = singleEvent.ID;
            eventViewModel.Name              = singleEvent.Name;
            eventViewModel.Type              = singleEvent.Type;
            eventViewModel.TicketQuantity    = singleEvent.TicketQuantity;
            eventViewModel.ScheduledDateTime = singleEvent.ScheduledDateTime;
            eventViewModel.IsRecurring       = eventViewModel.SetEventRecurringValue(singleEvent.IsRecurring);
            eventViewModel.Location          = singleEvent.Location;
            eventViewModel.Link              = singleEvent.Link;
            eventViewModel.Description       = singleEvent.Description;
            eventViewModel.OrganizationID    = singleEvent.OrganizationID;
            eventViewModel.TicketPrice       = db.Tickets.SingleOrDefault(x => x.EventID == eventID).TicketPrice;

            return(View(eventViewModel));
        }
Example #3
0
        public ActionResult PayForEvent(int eventID)
        {
            EventPlusEntities db = new EventPlusEntities();
            int attendeeID       = Int32.Parse(Session["AttendeeID"].ToString());

            Payment existingPayment = db.Payments.SingleOrDefault(x => x.AttendeeID == attendeeID);

            if (existingPayment == null)
            {
                Ticket ticket = db.Tickets.SingleOrDefault(x => x.EventID == eventID);

                Payment payment = new Payment();

                payment.TicketID        = ticket.ID;
                payment.AttendeeID      = attendeeID;
                payment.PaymentDateTime = System.DateTime.Now;

                db.Payments.Add(payment);
                db.SaveChanges();
            }



            return(RedirectToAction("AllEvents"));
        }
Example #4
0
        public ActionResult UserDetail(UserViewModel userViewModel)
        {
            EventPlusEntities db = new EventPlusEntities();

            User user = db.Users.SingleOrDefault(x => x.ID == userViewModel.ID);

            user.ID = userViewModel.ID;
            if (user.Email != userViewModel.Email && db.Users.SingleOrDefault(u => u.Email == userViewModel.Email) == null)
            {
                user.Email = userViewModel.Email;
            }

            user.First_Name = userViewModel.First_Name;
            user.Last_Name  = userViewModel.Last_Name;
            user.Address    = userViewModel.Address;
            user.Phone      = userViewModel.Phone;
            user.Gender     = userViewModel.GetUserGenderValue(userViewModel.Gender);
            if (userViewModel.DateOfBirth.Year != 1)
            {
                user.DateOfBirth = userViewModel.DateOfBirth;
            }
            db.SaveChanges();
            if (userViewModel.OrganizationName != null && userViewModel.OrganizationName != "")
            {
                Organization organization = db.Organizations.SingleOrDefault(x => x.UserID == userViewModel.ID);
                organization.Name = userViewModel.OrganizationName;
                db.SaveChanges();
            }

            return(RedirectToAction("AllUsers"));
        }
Example #5
0
        public ActionResult CreateEvent()
        {
            EventPlusEntities   db   = new EventPlusEntities();
            List <Organization> list = db.Organizations.ToList();

            ViewBag.OrganizationList = new SelectList(list, "ID", "Name");
            return(View());
        }
Example #6
0
        public ActionResult SignUp(UserViewModel userViewModel)
        {
            try
            {
                EventPlusEntities db = new EventPlusEntities();
                User user            = new User();

                user.First_Name = userViewModel.First_Name;
                user.Last_Name  = userViewModel.Last_Name;
                user.Email      = userViewModel.Email;
                user.Password   = userViewModel.Password;
                user.Address    = userViewModel.Address;
                user.Phone      = userViewModel.Phone;
                user.IsDeleted  = 0;
                if (userViewModel.Gender == Gender.Female)
                {
                    user.Gender = "Female";
                }
                else
                {
                    user.Gender = "Male";
                }
                user.DateOfBirth = userViewModel.DateOfBirth;

                if (db.Users.SingleOrDefault(x => x.Email == userViewModel.Email) == null)
                {
                    db.Users.Add(user);
                    db.SaveChanges();

                    int lastUserID = user.ID;

                    Attendee attendee = new Attendee();
                    attendee.UserID             = lastUserID;
                    attendee.NoOfEventsAttended = 0;
                    db.Attendees.Add(attendee);
                    db.SaveChanges();

                    if (userViewModel.OrganizationName != null && userViewModel.OrganizationName != "")
                    {
                        Organization organization = new Organization();
                        organization.UserID = lastUserID;
                        organization.Name   = userViewModel.OrganizationName;
                        db.Organizations.Add(organization);
                        db.SaveChanges();
                    }

                    return(RedirectToAction("SignIn"));
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(View());
        }
Example #7
0
        public ActionResult AllEvents()
        {
            EventPlusEntities     db                  = new EventPlusEntities();
            List <Event>          eventsList          = db.Events.ToList();
            EventViewModel        eventViewModel      = new EventViewModel();
            List <EventViewModel> eventViewModelsList = eventsList.Where(x => x.IsDeleted == 0).Select(x => new EventViewModel {
                ID = x.ID, Name = x.Name, Type = x.Type, TicketQuantity = x.TicketQuantity, ScheduledDateTime = x.ScheduledDateTime, IsRecurring = eventViewModel.SetEventRecurringValue(x.IsRecurring), Location = x.Location, Link = x.Link, Description = x.Description, OrganizationID = x.OrganizationID
            }).ToList();

            return(View(eventViewModelsList));
        }
Example #8
0
        public ActionResult DeleteEvent(int eventID)
        {
            EventPlusEntities db = new EventPlusEntities();

            Event evt = db.Events.SingleOrDefault(x => x.ID == eventID);

            evt.IsDeleted = 1;
            db.SaveChanges();

            return(RedirectToAction("AllEvents"));
        }
Example #9
0
        public ActionResult DeleteUser(int userID)
        {
            EventPlusEntities db = new EventPlusEntities();

            User user = db.Users.SingleOrDefault(x => x.ID == userID);

            user.IsDeleted = 1;
            db.SaveChanges();

            return(RedirectToAction("AllUsers"));
        }
Example #10
0
        public ActionResult CreateEvent(EventViewModel eventViewModel)
        {
            try
            {
                EventPlusEntities db  = new EventPlusEntities();
                Event             evt = new Event();

                List <Organization> list = db.Organizations.ToList();
                ViewBag.OrganizationList = new SelectList(list, "ID", "Name");

                evt.Name              = eventViewModel.Name;
                evt.Type              = eventViewModel.Type;
                evt.TicketQuantity    = eventViewModel.TicketQuantity;
                evt.ScheduledDateTime = eventViewModel.ScheduledDateTime;
                evt.IsRecurring       =
                    eventViewModel.GetEventRecurringValue(eventViewModel.IsRecurring);
                evt.Location    = eventViewModel.Location;
                evt.Link        = eventViewModel.Link;
                evt.Description = eventViewModel.Description;
                evt.IsDeleted   = 0;
                if (Session["UserType"] == "Admin")
                {
                    evt.OrganizationID = eventViewModel.OrganizationID;
                }
                else
                {
                    evt.OrganizationID = Int32.Parse(Session["OrganizationID"].ToString());
                }

                db.Events.Add(evt);
                db.SaveChanges();
                int lastestEvtId = evt.ID;

                Ticket ticket = new Ticket();
                ticket.TicketPrice = eventViewModel.TicketPrice;
                ticket.EventID     = lastestEvtId;
                ticket.TicketName  = eventViewModel.Name + " Ticket";
                db.Tickets.Add(ticket);
                db.SaveChanges();
            }
            catch (Exception ex)
            {
                throw ex;
            }


            return(RedirectToAction("AllEvents"));
        }
Example #11
0
        public ActionResult AllUsers()
        {
            EventPlusEntities    db                 = new EventPlusEntities();
            List <User>          usersList          = db.Users.ToList();
            UserViewModel        userViewModel      = new UserViewModel();
            List <UserViewModel> userViewModelsList = usersList.Where(x => x.IsDeleted == 0).Select(
                x => new UserViewModel {
                ID          = x.ID,
                Email       = x.Email,
                Password    = x.Password,
                First_Name  = x.First_Name,
                Last_Name   = x.Last_Name,
                Address     = x.Address,
                Phone       = x.Phone,
                Gender      = userViewModel.SetUserGenderValue(x.Gender),
                DateOfBirth = x.DateOfBirth,
            }
                ).ToList();

            return(View(userViewModelsList));
        }
Example #12
0
        public ActionResult EventDetail(EventViewModel eventViewModel)
        {
            EventPlusEntities db = new EventPlusEntities();

            Event evt = db.Events.SingleOrDefault(x => x.ID == eventViewModel.ID);

            List <Organization> list = db.Organizations.ToList();

            ViewBag.OrganizationList = new SelectList(list, "ID", "Name");

            evt.Name           = eventViewModel.Name;
            evt.Type           = eventViewModel.Type;
            evt.TicketQuantity = eventViewModel.TicketQuantity;
            if (eventViewModel.ScheduledDateTime.Year != 1)
            {
                evt.ScheduledDateTime = eventViewModel.ScheduledDateTime;
            }

            evt.IsRecurring = eventViewModel.GetEventRecurringValue(eventViewModel.IsRecurring);
            evt.Location    = eventViewModel.Location;
            evt.Link        = eventViewModel.Link;
            evt.Description = eventViewModel.Description;
            if (Session["UserType"] == "Admin")
            {
                evt.OrganizationID = eventViewModel.OrganizationID;
            }
            else
            {
                evt.OrganizationID = Int32.Parse(Session["OrganizationID"].ToString());
            }
            db.SaveChanges();

            Ticket ticket = db.Tickets.SingleOrDefault(x => x.EventID == eventViewModel.ID);

            ticket.TicketPrice = eventViewModel.TicketPrice;

            db.SaveChanges();

            return(RedirectToAction("AllEvents"));
        }
Example #13
0
        public ActionResult UserDetail(int userID)
        {
            EventPlusEntities db        = new EventPlusEntities();
            User          singleUser    = db.Users.SingleOrDefault(x => x.ID == userID);
            UserViewModel userViewModel = new UserViewModel();

            userViewModel.ID          = singleUser.ID;
            userViewModel.Email       = singleUser.Email;
            userViewModel.First_Name  = singleUser.First_Name;
            userViewModel.Last_Name   = singleUser.Last_Name;
            userViewModel.Address     = singleUser.Address;
            userViewModel.Phone       = singleUser.Phone;
            userViewModel.Gender      = userViewModel.SetUserGenderValue(singleUser.Gender);
            userViewModel.DateOfBirth = singleUser.DateOfBirth;

            if (singleUser.Organizations.Count > 0)
            {
                userViewModel.OrganizationName = db.Organizations.SingleOrDefault(x => x.UserID == userID).Name;
            }


            return(View(userViewModel));
        }