示例#1
0
 public static User CreateAnonymous(String IPAddress)
 {
     User user = new User();
     user.UserName = Guid.NewGuid().ToString();
     user.EmailOrIPAddress = IPAddress;
     return EntityMappingContext.Current.Users.Add(user);
 }
示例#2
0
 public static User Create(String userName, String emailAddress)
 {
     User user = new User();
     user.UserName = userName;
     user.EmailOrIPAddress = emailAddress;
     return EntityMappingContext.Current.Users.Add(user);
 }
示例#3
0
        public ActionResult Create(User user)
        {
            if (ModelState.IsValid)
            {
                db.Users.Add(user);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(user);
        }
示例#4
0
 ChangeSubset GetUsersChangeSubset(User user)
 {
     ChangeSubset result = null;
     foreach (ChangeSubset entry in GetUsersChangeSet(user).ChangeSubsets.OrderByDescending(_ => _.Id).Take(1))
         result = entry;
     if (result == null)
     {
         result = new ChangeSubset(SpringboardState.Create(GetCurrentActiveEdits()));
         GetUsersChangeSet(user).ChangeSubsets.Add(result);
     }
     return result;
 }
示例#5
0
 ChangeSet GetUsersChangeSet(User user)
 {
     ChangeSet result = null;
     foreach (ChangeSet entry in (from changeSet in ChangeSets where changeSet.Owner == user orderby changeSet.Id descending select changeSet).Take(1))
         result = entry;
     if (result == null)
     {
         result = new ChangeSet();
         user.ChangeSets.Add(result);
         this.ChangeSets.Add(result);
     }
     return result;
 }
示例#6
0
 public IEnumerable<EditOperation> GetUsersOpenEditOperations(User user)
 {
     return EntityMappingContext.Current.EditOperations.Where(_ => _.IsClosed == false && _.Document == this && _.User == user);
 }
示例#7
0
        public void AppendHunk(Hunk hunk, User user)
        {
            foreach (EditOperation editOperation in GetUsersOpenEditOperations(user).OrderByDescending(lambdaEditOperation => lambdaEditOperation.Hunks.Min(lambdaHunk => lambdaHunk.StartIndex)))
            {
                editOperation.MergeHunk(ref hunk);
                if (hunk == null) break;
            }
            if (hunk is InsertionHunk)
            {
                var operation = new InsertOperation();
                GetUsersChangeSubset(user).EditOperations.Add(operation);

                operation.Hunks.Add(hunk);
            }
            else if (hunk is DeletionHunk)
            {
                var operation = new DeleteOperation();
                GetUsersChangeSubset(user).EditOperations.Add(operation);
                operation.Hunks.Add(hunk);
            }
            else throw new InvalidOperationException("Cannot create No-Operation operation");
        }
示例#8
0
 public ActionResult Edit(User user)
 {
     if (ModelState.IsValid)
     {
         db.Entry(user).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(user);
 }
示例#9
0
 internal void ReceiveHunks(Document document, User user, int clientUpdateStamp, int serverUpdateStamp, Hunk[] hunks)
 {
     DocumentEditStateCollection documentEditStates = DataStoreClient.Get();
     DocumentEditState documentEditState = documentEditStates[document];
 }