public ActionResult JoinedEvents()
        {
            var currentuser  = CurrentUser();
            var Events       = AllEvents();
            var JoinedEvents = new JoinedEvents();
            //int?[] productModelIds = { 19, 26, 118 };
            //var products = AWEntities.Products.
            //    Where(p => productModelIds.Contains(p.ProductModelID));
            var joins = JoinedEvents.EventsJoined(currentuser);

            Events.ToList();
            joins.ToList();
            var Ev = Events.Intersect(joins, new EventIdComparer()).ToList();

            var viewModel = new UserEventViewModel
            {
                Person   = currentuser,
                Events   = Ev,
                UserJoin = new JoinedEvents
                {
                    JoinedPerson = currentuser,
                }
            };

            return(View("Index", viewModel));
        }
        public ActionResult JoinedUsers(int id)
        {
            var Events      = AllEvents();
            var Event       = Events.FirstOrDefault(e => e.Id == id);
            var joinedUsers = new JoinedEvents();
            var Persons     = joinedUsers.PersonsJoined(Event);

            return(PartialView(Persons));
        }
        public ActionResult JoinEvent(int Id)
        {
            var UserToJoin      = CurrentUser();
            var EventToBeJoined = AllEvents().FirstOrDefault(e => e.Id == Id);

            if (EventToBeJoined == null)
            {
                return(HttpNotFound());
                //return Content("Event Not found");
            }
            //validatio
            if (EventToBeJoined.Owner != UserToJoin)
            {
                var JoinedEvents = new JoinedEvents
                {
                    JoinedPerson = UserToJoin,
                    Event        = EventToBeJoined,
                };
                var common = db.JoinedEvents.Where(p => p.JoinedPerson.Id == UserToJoin.Id).Where(e => e.Event.Id == EventToBeJoined.Id).ToList();
                var result = JoinedEvents.IsUserJoined(UserToJoin, EventToBeJoined);
                if (result)
                {
                    db.JoinedEvents.Add(JoinedEvents);
                }
                else
                {
                    foreach (var commonJoin in common)
                    {
                        db.JoinedEvents.Remove(commonJoin);
                    }
                }
                db.SaveChanges();

                //return Content("Joined");
            }


            return(new EmptyResult());
        }