public Session(SessionDao dao) { Id = dao.PartitionKey; Expiry = dao.Expiry; Username = dao.Username; Organisations = JsonConvert.DeserializeObject <List <SessionDao.Organisation> >(dao.Organisations); }
private static SessionDao CreateSessionObject( IEnumerable <Organization> orgs, Account user) { var sessionId = Guid.NewGuid().ToString(); var organisations = orgs.Select(x => new SessionDao.Organisation { Id = x.Id, Name = x.Login }); var organisationsSerialised = JsonConvert.SerializeObject(organisations); var session = new SessionDao { PartitionKey = sessionId, RowKey = sessionId, Timestamp = DateTimeOffset.Now, Organisations = organisationsSerialised, Username = user.Login, Expiry = DateTimeOffset.Now.AddHours(8) }; return(session); }