partial void DeleteAspNetUsers_Hangout(AspNetUsers_Hangout instance);
 partial void UpdateAspNetUsers_Hangout(AspNetUsers_Hangout instance);
        public void WaitlistHangout(string userId, int hangoutId)
        {
            if (AspNetUsers_Hangout_db.AspNetUsers_Hangouts.Any())
            {
                var UserHangout = (from a in AspNetUsers_Hangout_db.AspNetUsers_Hangouts
                                   where a.HangoutId == hangoutId && a.AspNetUsers == userId
                                   select a).SingleOrDefault();

                if (UserHangout == null)
                {
                    UserHangout = new AspNetUsers_Hangout
                    {
                        AspNetUsers = userId,
                        HangoutId = hangoutId,
                        IsRSVPd = false,
                        IsWaitlist = true
                    };

                    AspNetUsers_Hangout_db.AspNetUsers_Hangouts.InsertOnSubmit(UserHangout);
                }
                else
                {
                        UserHangout.IsWaitlist = true;
                        UserHangout.IsRSVPd = false;

                }

            }
            else
            {

                var UserHangout = new AspNetUsers_Hangout
                {
                    AspNetUsers = userId,
                    HangoutId = hangoutId,
                    IsRSVPd = false,
                    IsWaitlist = true
                };

                AspNetUsers_Hangout_db.AspNetUsers_Hangouts.InsertOnSubmit(UserHangout);
            }

            try
            {
                AspNetUsers_Hangout_db.SubmitChanges();

            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                // Make some adjustments.
                // ...
                // Try again.
                AspNetUsers_Hangout_db.SubmitChanges();
            }
        }
 partial void InsertAspNetUsers_Hangout(AspNetUsers_Hangout instance);
        public void JoinHangout(string userId, int hangoutId)
        {
            var Hangout = (from a in Hangout_db.Hangouts
                           where a.Id == hangoutId
                           select a).SingleOrDefault();
            var UserAccount = (from a in AspNetUsers_db.AspNetUsers
                               where a.Id == userId
                               select a).SingleOrDefault();
            if ((Hangout.AttendeeCount < Hangout.PartySize && Hangout.GenderRatio == false) ||
                (Hangout.AttendeeCount < Hangout.PartySize && Hangout.GenderRatio == true &&
                (UserAccount.Gender == 0 && Hangout.MaleAttendingCount < Hangout.PartySize / 2) || (UserAccount.Gender == 1 && Hangout.FemaleAttendingCount < Hangout.PartySize / 2)))
            {
                //if (AspNetUsers_Hangout_db.AspNetUsers_Hangouts.Any())
                //    {
                var UserHangout = (from a in AspNetUsers_Hangout_db.AspNetUsers_Hangouts
                                   where a.HangoutId == hangoutId && a.AspNetUsers == userId
                                   select a).SingleOrDefault();

                if (UserHangout == null)
                {
                    UserHangout = new AspNetUsers_Hangout
                    {
                        AspNetUsers = userId,
                        HangoutId = hangoutId,
                        IsRSVPd = true,
                        IsWaitlist = false,
                        Showed = true
                    };

                    AspNetUsers_Hangout_db.AspNetUsers_Hangouts.InsertOnSubmit(UserHangout);
                }
                else
                {
                    UserHangout.IsRSVPd = true;
                }
                //}

                try
                {
                    if (UserAccount.Gender == 0)
                    {
                        Hangout.MaleAttendingCount++;
                    }
                    else
                    {
                        Hangout.FemaleAttendingCount++;
                    }
                    Hangout.AttendeeCount++;

                    ActivityLog actLog = new ActivityLog
                    {
                        AspNetUserId = UserAccount.Id,
                        HangoutId = Hangout.Id,
                        TimeStamp = DateTime.UtcNow,
                        ActivityType = (int)ActivityType.Join
                    };

                    ActivityLog_db.ActivityLogs.InsertOnSubmit(actLog);

                    Hangout_db.SubmitChanges();
                    AspNetUsers_Hangout_db.SubmitChanges();
                    ActivityLog_db.SubmitChanges();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    // Make some adjustments.
                    // ...
                    // Try again.
                    Hangout_db.SubmitChanges();
                    AspNetUsers_Hangout_db.SubmitChanges();
                    ActivityLog_db.SubmitChanges();
                }
            }
            else
            {
                // Hangout too full/Hangout has too many boys/girls. Cant join.
            }
        }