public static Session Map(this Data.Session s) { Session session = new Session() { ID = s.ID, Name = s.Name, Description = s.Description, Level = s.Level, Status = s.Status, Location = s.Location, Speaker = s.Speaker.FirstName + " " + s.Speaker.LastName, ImageUrl = s.Speaker.ImageUrl, SpeakerID = s.Speaker.ID, TrackID = s.Track_ID, Track = s.Track == null ? "" : s.Track.Name, TimeslotID = s.Timeslot_ID, StartTime = s.Timeslot == null ? null : s.Timeslot.StartTime, EndTime = s.Timeslot == null ? null : s.Timeslot.EndTime, TagID = s.Tag_ID, EventID = s.Event_ID }; return(session); }
public void AttendSession(int personId, int sessionId) { using (OCCDB db = new OCCDB()) { // 1. delete old one Data.Session newSession = db.Sessions.Find(sessionId); if (newSession == null) { throw new Exception("Session not found"); } var oldSession = (from sa in db.SessionAttendees.Include("Session.Timeslot") where sa.Person_ID == personId && sa.Session.ID == sessionId select sa).SingleOrDefault(); //if (oldSession != null) // db.SessionAttendees.Remove(oldSession); if (oldSession == null) { // 2. insert new one db.SessionAttendees.Add(new OCC.Data.SessionAttendee() { Person_ID = personId, Session_ID = sessionId, Comment = string.Empty, SessionRating = 0, SpeakerRating = 0 }); } db.SaveChanges(); } }
public void WhenGettingSessionPropertiesAreRetrievedCorrectly() { // Assemble var dbContext = new InMemoryOCCDB() .WithEvent("Test Code Camp") .WithPerson("Test", "Speaker"); _expectedEvent = dbContext.Events.First(); _expectedSpeaker = dbContext.People.First(); _expectedSession = new Data.Session { Description = "This is the event", Event_ID = _expectedEvent.ID, Level = 300, Location = "The really far building", Name = "Best .NET Session", Speaker_ID = _expectedSpeaker.ID, Status = "Still Happening", }; dbContext.Sessions.Add(_expectedSession); dbContext.SaveChanges(); var service = TestHelper.GetTestService(dbContext); // Act _actualSession = service.GetSession(_expectedSession.ID); // Assert }
public SessionSearchViewModel(Data.Session sessionDTO) { Id = sessionDTO.Id; Course = sessionDTO.Course; Instructor = sessionDTO.Instructor; MeetingDate = sessionDTO.MeetingDate; MeetingTime = sessionDTO.MeetingTime; Occupancy = sessionDTO.Occupancy; Description = sessionDTO.Description; }
public SessionViewModel(Data.Session row) { this.Id = row.Id; this.Title = row.Title; this.Description = row.Description; this.Presenter = row.Presenter; this.Room = row.Room; this.Time = row.Time; this.Occupancy = row.Occupancy; this.CurrentEnrollment = row.CurrentEnrollment; }
public SessionViewModel(Data.Session row) { //row.SessionID will be null if the session is deleted this.SessionId = row.SessionId; this.SessionTitle = row.SessionTitle; this.SessionDescription = row.SessionDescription; this.SessionPresenter = row.SessionPresenter; this.SessionAddress = row.SessionAddress; this.SessionRoom = row.SessionRoom; this.SessionSeatsAvailable = row.SessionSeatsAvailable; }
protected void LoginButtonClick(object sender, ImageClickEventArgs e) { String Collectpassword = Utility.GetMd5Sum(password.Text); Simplicity.Data.User user = (from u in DatabaseContext.Users where u.Email == username.Text && u.Password == Collectpassword && u.Verified == true && u.Enabled == true select u).FirstOrDefault(); if (user != null) { Simplicity.Data.Session session = new Data.Session(); session.SessionUID = System.Guid.NewGuid().ToString(); session.User = user; session.StartTime = DateTime.Now; session.LastActivityTime = DateTime.Now; session.EndTime = DateTime.Now.AddMinutes(30); session.IP = Request.UserHostAddress; DatabaseContext.AddToSessions(session); DatabaseContext.SaveChanges(); FormsAuthentication.SetAuthCookie(session.SessionUID, false); Session[WebConstants.Session.USER_ID] = user.UserID; Session["userName"] = user.Email; Session.Timeout = 30; log.Info("User successfully login"); if (user.Type.Equals("ADMIN")) { Session["admin"] = "true"; } if (Session[WebConstants.Session.RETURN_URL] != null) { String redirectURL = (string)Session[WebConstants.Session.RETURN_URL]; Response.Redirect((string)Session[WebConstants.Session.RETURN_URL]); } else if (Request["GOTO_URL"] != null) { Response.Redirect((string)Request["GOTO_URL"]); } else { Response.Redirect("Default.aspx"); } } else { SetErrorMessage(WebConstants.Messages.Error.CANNOT_LOGIN); } }
public async Task <ActionResult <SessionResponse> > Post(ConferenceDTO.Session input) { var session = new Data.Session { Title = input.Title, StartTime = input.StartTime, EndTime = input.EndTime, Abstract = input.Abstract, TrackId = input.TrackId }; _context.Sessions.Add(session); await _context.SaveChangesAsync(); var result = session.MapSessionResponse(); return(CreatedAtAction(nameof(Get), new { id = result.Id }, result)); }
public ActionResult <SessionResponse> Post(ConferenceDTO.Session input) { var session = new Data.Session { Title = input.Title, ConferenceID = input.ConferenceID, StartTime = input.StartTime, EndTime = input.EndTime, Abstract = input.Abstract, TrackId = input.TrackId }; _db.Sessions.Add(session); _db.SaveChangesAsync() .GetAwaiter() .GetResult(); var result = session.MapSessionResponse(); return(CreatedAtAction(nameof(Get), new { id = result.ID }, result)); }
public static async Task <Statuses> StartSessionAsync(this ISessionsApi api, GoogleApiClient client, Data.Session session) { return((await api.StartSession(client, session)).JavaCast <Statuses> ()); }
private static ConferenceDTO.SessionResponse MapSessionResponse(Data.Session session) { return(session.MapSessionResponse()); }
private static bool IsSessionWithinDateRange(DateTimeOffset?fromDate, DateTimeOffset?toDate, Data.Session s) { var startTime = s.StartTime ?? DateTimeOffset.MinValue; var endTime = s.EndTime ?? DateTimeOffset.MaxValue; return(startTime.CompareTo(fromDate.Value) >= 0 && endTime.CompareTo(toDate.Value) <= 0); }