예제 #1
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"));
        }
예제 #2
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());
        }
예제 #3
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"));
        }
예제 #4
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"));
        }
예제 #5
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"));
        }
예제 #6
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"));
        }
예제 #7
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"));
        }