Esempio n. 1
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);
        }
Esempio n. 2
0
        public static void PermanentlyDeleteSharedChore(int sharedChoreId)
        {
            using (ProMaDB scope = new ProMaDB())
            {
                SharedChore sharedChore = SharedChoreHandler.GetSharedChore(sharedChoreId);

                foreach (CompletedChore currentCompletedChore in CompletedChoreHandler.GetAllCompletedChoreItems(sharedChore.SharedChoreId))
                {
                    CompletedChoreHandler.UnCompleteChore(sharedChore.SharedChoreId, currentCompletedChore.ChoreDate);
                }

                foreach (SharedChoreMembership currentSharedChoreMembership in SharedChoreMembershipHandler.GetSharedChoreMembershipsForChore(sharedChoreId))
                {
                    SharedChoreMembershipHandler.RemoveSharedChoreMembership(sharedChoreId, currentSharedChoreMembership.UserId);
                }

                scope.Remove(sharedChore);
                scope.SaveChanges();
            }
        }