public static void AddFriendship(Friendship toAdd) { using (ProMaDB scope = new ProMaDB()) { scope.Friendships.Add(toAdd); scope.Entry(toAdd).State = EntityState.Added; scope.SaveChanges(); } }
public static void UpdateSharedChoreMembership(SharedChoreMembership toUpdate) { using (ProMaDB scope = new ProMaDB()) { scope.SharedChoreMemberships.Attach(toUpdate); scope.Entry(toUpdate).State = EntityState.Modified; scope.SaveChanges(); } }
public static void UpdatePostedNote(PostedNote toUpdate) { using (ProMaDB scope = new ProMaDB()) { scope.PostedNotes.Attach(toUpdate); scope.Entry(toUpdate).State = EntityState.Modified; scope.SaveChanges(); } }
public static void AddPostedNote(PostedNote toAdd) { using (ProMaDB scope = new ProMaDB()) { scope.PostedNotes.Add(toAdd); scope.Entry(toAdd).State = EntityState.Added; scope.SaveChanges(); } }
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); }
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); }
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); }
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); } }
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); } }
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(); } } }