Ejemplo n.º 1
0
 public static void AddFriendship(Friendship toAdd)
 {
     using (ProMaDB scope = new ProMaDB())
     {
         scope.Friendships.Add(toAdd);
         scope.Entry(toAdd).State = EntityState.Added;
         scope.SaveChanges();
     }
 }
Ejemplo n.º 2
0
 public static void UpdateSharedChoreMembership(SharedChoreMembership toUpdate)
 {
     using (ProMaDB scope = new ProMaDB())
     {
         scope.SharedChoreMemberships.Attach(toUpdate);
         scope.Entry(toUpdate).State = EntityState.Modified;
         scope.SaveChanges();
     }
 }
Ejemplo n.º 3
0
 public static void UpdatePostedNote(PostedNote toUpdate)
 {
     using (ProMaDB scope = new ProMaDB())
     {
         scope.PostedNotes.Attach(toUpdate);
         scope.Entry(toUpdate).State = EntityState.Modified;
         scope.SaveChanges();
     }
 }
Ejemplo n.º 4
0
 public static void AddPostedNote(PostedNote toAdd)
 {
     using (ProMaDB scope = new ProMaDB())
     {
         scope.PostedNotes.Add(toAdd);
         scope.Entry(toAdd).State = EntityState.Added;
         scope.SaveChanges();
     }
 }
Ejemplo n.º 5
0
        public static void AddNoteType(NoteType toAdd)
        {
            using (ProMaDB scope = new ProMaDB())
            {
                scope.NoteTypes.Add(toAdd);
                scope.Entry(toAdd).State = EntityState.Added;
                scope.SaveChanges();
            }

            ThisCache.Add(toAdd);
        }
Ejemplo n.º 6
0
        public static void AddFriendshipRequest(FriendshipRequest toAdd)
        {
            using (ProMaDB scope = new ProMaDB())
            {
                scope.FriendshipRequests.Add(toAdd);
                scope.Entry(toAdd).State = EntityState.Added;
                scope.SaveChanges();
            }

            AddToUserFriendshipCacheIterator(toAdd.SenderId);
            AddToUserFriendshipCacheIterator(toAdd.RecipientId);
        }
Ejemplo n.º 7
0
        public static void AddSharedChore(SharedChore toAdd, int seedUserId)
        {
            using (ProMaDB scope = new ProMaDB())
            {
                scope.SharedChores.Add(toAdd);
                scope.Entry(toAdd).State = EntityState.Added;
                scope.SaveChanges();
            }

            SharedChoreMembershipHandler.AddSharedChoreMembership(toAdd.SharedChoreId, seedUserId);

            // we just added the chore, so the only possible user on it is the logged in user
            CompletedChoreHandler.AddToUserChoreCacheIterator(seedUserId);
        }
Ejemplo n.º 8
0
        public static void AddProMaUser(ProMaUser toAdd)
        {
            using (ProMaDB scope = new ProMaDB())
            {
                scope.ProMaUsers.Add(toAdd);
                scope.Entry(toAdd).State = EntityState.Added;
                scope.SaveChanges();
            }

            lock (ThisCache)
            {
                ThisCache.Add(toAdd);
            }
        }
Ejemplo n.º 9
0
        public static void UpdateNoteType(NoteType toUpdate)
        {
            using (ProMaDB scope = new ProMaDB())
            {
                scope.NoteTypes.Attach(toUpdate);
                scope.Entry(toUpdate).State = EntityState.Modified;
                scope.SaveChanges();
            }

            lock (ThisCache)
            {
                ThisCache.RemoveAll(x => x.NoteTypeId == toUpdate.NoteTypeId);
                ThisCache.Add(toUpdate);
            }
        }
Ejemplo n.º 10
0
        public static void AddNoteTypeMembership(NoteTypeMembership toAdd)
        {
            lock (TransactionLocks.StringLock)
            {
                using (ProMaDB scope = new ProMaDB())
                {
                    // if this membership already exists, recreate it with the new information
                    NoteTypeMembership existingMembership = scope.NoteTypeMemberships.FirstOrDefault(x => x.UserId == toAdd.UserId && x.NoteTypeId == toAdd.NoteTypeId);
                    if (existingMembership != null)
                    {
                        scope.NoteTypeMemberships.Remove(existingMembership);
                        scope.SaveChanges();
                    }

                    scope.NoteTypeMemberships.Add(toAdd);
                    scope.Entry(toAdd).State = EntityState.Added;
                    scope.SaveChanges();
                }
            }
        }