Esempio n. 1
0
        public void CreateEvent(string name, DateTime startingDate, DateTime endingDate, DateTime startingHour, DateTime endingHour, string description,
                                List <User> participantsList, int minParticipants, int maxParticipants, string locationAddress)
        {
            EventC crtEvent = new EventC(Statics.GetMaxId(TabeleDB.Events), name, startingDate, endingDate, startingHour, endingHour, description,
                                         participantsList, minParticipants, maxParticipants, locationAddress);

            this.CreatedEventsList.Add(crtEvent);

            SqlCommand addEventDb = new SqlCommand
            {
                Connection  = Statics.conn,
                CommandText = "INSERT INTO Event VALUES(@id, @name, @stDate, @endDate, @stHour, @endHour, @desc, " +
                              "@partic, @minP, @maxP, @addr)"
            };

            addEventDb.Parameters.AddWithValue("@id", crtEvent.GetId());
            addEventDb.Parameters.AddWithValue("@name", crtEvent.GetName());
            addEventDb.Parameters.AddWithValue("@stDate", crtEvent.GetStartingDate());
            addEventDb.Parameters.AddWithValue("@endDate", crtEvent.GetEndingDate());
            addEventDb.Parameters.AddWithValue("@stHour", crtEvent.GetStartingHour());
            addEventDb.Parameters.AddWithValue("@endHour", crtEvent.GetEndingDate());
            addEventDb.Parameters.AddWithValue("@desc", crtEvent.GetDescription());
            addEventDb.Parameters.AddWithValue("@partic", crtEvent.GetParticipantsList());
            addEventDb.Parameters.AddWithValue("@minP", crtEvent.GetMinParticipants());
            addEventDb.Parameters.AddWithValue("@maxP", crtEvent.GetMinParticipants());
            addEventDb.Parameters.AddWithValue("@addr", crtEvent.GetLocationAddress());
            addEventDb.ExecuteNonQuery();

            UpdateUserCreatedEvents();
        }
Esempio n. 2
0
        private void JoinEvent(EventC crtEvent, bool join)
        {
            if (join == true)
            {
                crtEvent.GetParticipantsList().Add(this);
            }
            else
            {
                crtEvent.GetParticipantsList().Remove(this);
            }

            SqlCommand updateEvent = new SqlCommand
            {
                Connection  = Statics.conn,
                CommandText = "UPDATE Event SET ParticipantsList = @list WHERE Id = @id"
            };

            updateEvent.Parameters.AddWithValue("@list", Statics.SerializeObject(crtEvent.GetParticipantsList()));
            updateEvent.Parameters.AddWithValue("@id", crtEvent.GetId());
            updateEvent.ExecuteNonQuery();
        }