public void Handle(ScheduleMeetingCommand command) { var meeting = new MeetingFactory().Schedule(command.MeetingId, command.On, command.LocationId, command.SpeakerId, command.Capacity); repository.Add(meeting); //events from meeting? //AddNewSessionToSpeakerProfile(meeting.Id); //AddLocationUsage(meeting.Id) }
/// <summary> /// Извлекает все встречи репозитория. /// </summary> /// <returns></returns> public IEnumerable <Meeting> FindAll() { IMeetingFactory meetingFactory = new MeetingFactory(); List <Meeting> meetings = new List <Meeting>(); try { using (SqlConnection connection = new SqlConnection(_connectionString)) { connection.Open(); SqlCommand command = new SqlCommand("SELECT * FROM Meetings", connection); SqlDataReader reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { DateTime?note; if (reader.IsDBNull(3)) { note = null; } else { note = reader.GetDateTime(3); } meetings.Add(meetingFactory.Create(reader.GetInt32(0), reader.GetDateTime(1), reader.GetDateTime(2), note)); } } reader.Close(); connection.Close(); } } catch (Exception e) { throw new Exception(e.Message); } return(meetings); }