public void Create(Session session)
        {
            if (session == null)
                throw new ArgumentNullException("session");

            Cache.AddToList(session);
            Dispatcher.Dispatch(AddSession.CreateFrom(session));
        }
Exemplo n.º 2
0
 public static AddSession CreateFrom(Session session)
 {
     return new AddSession {
         EmailAddress = session.EmailAddress,
         Id = session.Id,
         Name = session.Name,
         UserId = session.UserId,
         UpdatedDate = session.UpdatedDate
     };
 }
        public IEnumerable<Common.Models.Page.Event> Log(Session session, string logName)
        {
            var events = All<Event>(x => x.LogName == logName);
            var measurements = All<Measurement>(x => x.LogName == logName);
            var tags = All<Tag>(x => x.LogName == logName);

            return events.OrderByDescending(x => x.Date).Select(x => new Common.Models.Page.Event {
                Date = x.Date,
                Measurements = measurements.Where(y => y.EventId == x.Id),
                Tags = tags.Where(y => y.EventId == x.Id).OrderBy(y => y.Name)
            });
        }
        public Session SignIn(string emailAddress, string password)
        {
            if (string.IsNullOrEmpty(emailAddress))
                throw new ArgumentNullException("emailAddress");
            if (string.IsNullOrEmpty(password))
                throw new ArgumentNullException("password");

            var isUserValidated = MembershipProvider.ValidateUser(emailAddress, password);
            if (!isUserValidated)
                return null;

            var token = Guid.NewGuid();
            var user = UserRepository.Email(emailAddress);
            var session = new Session { Id = token, UserId = user.Id, EmailAddress = user.EmailAddress, Name = user.Name };
            SessionRepository.Create(session);
            HttpContext.Current.Response.Cookies.Add(new HttpCookie("log-auth", token.ToString()));
            return session;
        }
 public IEnumerable<Tag> Log(Session session, string logName)
 {
     return All<Tag>().Where(x => x.LogName == logName);
 }
 public void SignOut(Session session)
 {
     Cache.RemoveFromList<Session>(session.Id);
     HttpRequestor.Post(DataServiceLocation + "sign-out");
 }
 public void Save(Session session, Log data)
 {
     HttpRequestor.Post(DataServiceLocation, data);
 }
 public dynamic TagRatios(Session session, string logName)
 {
     return HttpRequestor.Get<object>(DataServiceLocation + "tag-ratios", new {logName, auth = session.Id.ToString()});
 }
 public dynamic PopularDays(Session session, string logName)
 {
     return HttpRequestor.Get<object>(DataServiceLocation + "popular-days", new {logName, auth = session.Id.ToString()});
 }
 public dynamic Measurements(Session session, string logName)
 {
     return HttpRequestor.Get<object>(DataServiceLocation + "measurements", new {logName, auth = session.Id.ToString()});
 }
 public dynamic EventsOverTime(Session session, string logName)
 {
     return HttpRequestor.Get<object>(DataServiceLocation + "events-over-time", new {logName, auth = session.Id.ToString()});
 }