예제 #1
0
 public Program Load(User user, string name)
 {
     var code = _blobHelper.LoadText(user.UserId.ToToken(), name.ToToken());
     var program = new Program
                       {
                           AuthorId = user.WindowsLiveAnonymousId,
                           Name = name,
                           Code = Convert.ToBase64String(Encoding.UTF8.GetBytes(code)),
                       };
     program.Hash = Program.CreateHash(program);
     return program;
 }
예제 #2
0
        public User GetOrAdd(string windowsLiveAnonymousId)
        {
            var user = GetByWindowsLiveAnonymousId(windowsLiveAnonymousId);
            if (user == null)
            {
                user = new User
                           {
                               WindowsLiveAnonymousId = windowsLiveAnonymousId,
                               UserId = Guid.NewGuid(),
                           };
                try
                {
                    Context.AddObject(EntitySetName, user);
                    Context.SaveChangesWithRetries();
                }
                catch (StorageException)
                {
                    user = GetByWindowsLiveAnonymousId(windowsLiveAnonymousId);
                }
            }

            return user;
        }