Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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();
            }
        }
Ejemplo n.º 3
0
        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;
 }
Ejemplo n.º 5
0
 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;
 }
Ejemplo n.º 6
0
 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;
 }
Ejemplo n.º 7
0
        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);
            }
        }
Ejemplo n.º 8
0
        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));
        }
Ejemplo n.º 9
0
        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));
        }
Ejemplo n.º 10
0
 public static async Task <Statuses> StartSessionAsync(this ISessionsApi api, GoogleApiClient client, Data.Session session)
 {
     return((await api.StartSession(client, session)).JavaCast <Statuses> ());
 }
Ejemplo n.º 11
0
        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
        }
 private static ConferenceDTO.SessionResponse MapSessionResponse(Data.Session session)
 {
     return(session.MapSessionResponse());
 }
Ejemplo n.º 13
0
        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);
        }