public static void Create(Suggestion suggestion, string weekdays)
        {
            JoinedUser u = new JoinedUser
            {
                UserId = suggestion.CreatorId,
                Weekdays = weekdays
            };

            suggestion.JoinedUsers.Add(u);

            DataAccessLayer.SuggestionAccess.Create(suggestion);
        }
 public static void Add(JoinedUser joinedUser)
 {
     try
     {
         using (var db = new MyDbContext())
         {
             db.JoinedUser.Add(joinedUser);
             db.SaveChanges();
         }
     }
     catch (Exception e)
     {
         throw new DomainException("Could not add joined user", e);
     }
 }
        public static void Join(int userId, int suggestionId, string weekdays)
        {
            Suggestion suggestion = SuggestionBusiness.Get(suggestionId);

            // Join if not closed, not full and not already joined
            if (!suggestion.IsClosed && suggestion.JoinedUsers.Count < suggestion.MaximumUsers && HasUserJoined(userId, suggestion))
            {
                var joinedUser = new JoinedUser { UserId = userId, SuggestionId = suggestionId, Weekdays = weekdays };
                suggestion.JoinedUsers.Add(joinedUser);
                DataAccessLayer.JoinedUserAccess.Add(joinedUser);

                // Find a location and playdays if min users are set
                if (suggestion.JoinedUsers.Count >= suggestion.MinimumUsers)
                {
                    suggestion.MostPopularDays = SuggestionBusiness.GetBestDays(suggestion.Id);
                    suggestion.LocationId = LocationBusiness.Calculate(suggestion).Id;

                    // Close suggestion if max users reached
                    if (suggestion.JoinedUsers.Count == suggestion.MaximumUsers)
                    {
                        suggestion.IsClosed = true;
                    }

                    SuggestionBusiness.Update(suggestion, suggestion.CreatorId);
                }
            }
        }