コード例 #1
0
        public async Task RemoveCardFromCardListAsync(CardList cardList, Card card)
        {
            var foundCardList = await FindAndCheckNullabilityHelper <CardList> .InDatabaseAsync(context.CardLists, cardList, "Card list not found!", false);

            var foundCard = await FindAndCheckNullabilityHelper <Card> .InCollectionAsync(foundCardList.Cards, card, "Card not found!", false);

            foundCardList.Cards.Remove(foundCard);
        }
コード例 #2
0
        public async Task AddCardToCardListAsync(CardList cardList, Card card)
        {
            var foundCardList = await FindAndCheckNullabilityHelper <CardList> .InDatabaseAsync(context.CardLists, cardList, "Card list not found!", false);

            var foundCard = await FindAndCheckNullabilityHelper <Card> .InCollectionAsync(foundCardList.Cards, card, "Card is already in this card list!", true);

            foundCardList.Cards.Add(card);
        }
コード例 #3
0
        private async Task <User> FindUserAndCheckLoginAsync(User user, string msg, bool mustBeNull)
        {
            var users = await context.Users.ToListAsync();

            var foundUser = users.FirstOrDefault(x => x.Email.Equals(user.Email) && x.Password.Equals(user.Password));

            foundUser = FindAndCheckNullabilityHelper <User> .CheckNullable(foundUser, msg, mustBeNull);

            return(foundUser);
        }
コード例 #4
0
        private async Task <User> FindUserAndCheckAsync(User user, string msg, bool mustBeNull)
        {
            var users = await context.Users.ToListAsync();

            var foundUser = users.FirstOrDefault(x => x.CompareTo(user).Equals(0));

            foundUser = FindAndCheckNullabilityHelper <User> .CheckNullable(foundUser, msg, mustBeNull);

            return(foundUser);
        }
コード例 #5
0
        public async Task RemoveEntityAsync(T entity)
        {
            try
            {
                var found = await FindAndCheckNullabilityHelper <T> .InDatabaseAsync(set, entity, $"Entity of type {entity.GetType()} was not found", false);

                set.Remove(found);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #6
0
        public async Task AddEntityAsync(T entity)
        {
            try
            {
                var found = await FindAndCheckNullabilityHelper <T> .InDatabaseAsync(set, entity, $"Entity of type {entity.GetType()} is already in DB", true);

                set.Add(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #7
0
        public async Task RemoveUserFromCardAsync(Card card, User user)
        {
            try
            {
                var foundCard = await FindAndCheckNullabilityHelper <Card> .InDatabaseAsync(context.Cards, card, "Card not found!", false);

                var foundUser = await FindAndCheckNullabilityHelper <User> .InCollectionAsync(foundCard.Users, user, "User was not found!", false);

                foundCard.Users.Remove(foundUser);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #8
0
        public async Task AddUserToCardAsync(Card card, User user)
        {
            try
            {
                var foundCard = await FindAndCheckNullabilityHelper <Card> .InDatabaseAsync(context.Cards, card, "Card not found!", false);

                var foundUser = await FindAndCheckNullabilityHelper <User> .InCollectionAsync(foundCard.Users, user, "User is already assigned to this card!", true);

                foundCard.Users.Add(user);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #9
0
        public async Task RemoveLabelColorFromCardAsync(Card card, LabelColor labelColor)
        {
            try
            {
                var foundCard = await FindAndCheckNullabilityHelper <Card> .InDatabaseAsync(context.Cards, card, "Card not found!", false);

                var foundLabeColor = await FindAndCheckNullabilityHelper <LabelColor> .InCollectionAsync(foundCard.LabelColors, labelColor, "Label color was not found!", false);

                foundCard.LabelColors.Remove(foundLabeColor);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #10
0
        public async Task RenameCardListAsync(CardList cardList, string newName)
        {
            var foundCardList = await FindAndCheckNullabilityHelper <CardList> .InDatabaseAsync(context.CardLists, cardList, "Card list not found!", false);

            if (foundCardList.Name.Equals(newName))
            {
                throw new Exception("Names are equal!");
            }
            else
            {
                context.Entry <CardList>(foundCardList).State = EntityState.Detached;
                foundCardList.Name = newName;
                context.Entry <CardList>(foundCardList).State = EntityState.Modified;
            }
        }
コード例 #11
0
        public async Task RemoveCardListFromBoardAsync(Board board, CardList cardList)
        {
            try
            {
                var foundBoard = await FindAndCheckNullabilityHelper <Board> .InDatabaseAsync(context.Boards, board, "Board was not found!", false);

                var foundCardList = await FindAndCheckNullabilityHelper <CardList> .InCollectionAsync(foundBoard.CardLists, cardList, "Card list not found!", false);

                foundBoard.CardLists.Remove(foundCardList);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #12
0
        public async Task RemoveCommentFromCardAsync(Card card, Comment comment)
        {
            try
            {
                var foundCard = await FindAndCheckNullabilityHelper <Card> .InDatabaseAsync(context.Cards, card, "Card not found!", false);

                var foundComment = await FindAndCheckNullabilityHelper <Comment> .InCollectionAsync(foundCard.Comments, comment, "Comment was not found!", false);

                foundCard.Comments.Remove(foundComment);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #13
0
        public async Task AddLabelColorToCardAsync(Card card, LabelColor labelColor)
        {
            try
            {
                var foundCard = await FindAndCheckNullabilityHelper <Card> .InDatabaseAsync(context.Cards, card, "Card not found!", false);

                var foundLabeColor = await FindAndCheckNullabilityHelper <LabelColor> .InCollectionAsync(foundCard.LabelColors, labelColor, "Such label color is already assigned to this card!", true);

                labelColor.Cards.Add(foundCard);
                context.Set <LabelColor>().Add(labelColor);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #14
0
        public async Task AddCardListToBoardAsync(Board board, CardList cardList)
        {
            try
            {
                var foundBoard = await FindAndCheckNullabilityHelper <Board> .InDatabaseAsync(context.Boards, board, "Board was not found!", false);

                var foundCardList = await FindAndCheckNullabilityHelper <CardList> .InCollectionAsync(foundBoard.CardLists, cardList, "Card list is already in this board!", true);

                cardList.Board = foundBoard;
                context.Set <CardList>().Add(cardList);
                //foundBoard.CardLists.Add(cardList);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #15
0
        public async Task RemoveUserFromBoardAsync(Board board, User user)
        {
            try
            {
                var foundBoard = await FindAndCheckNullabilityHelper <Board> .InDatabaseAsync(context.Boards, board, "Board was not found!", false);

                var foundUser = await FindAndCheckNullabilityHelper <User> .InDatabaseAsync(context.Users, user, "User does not exist in database!", false);

                foundUser = await FindAndCheckNullabilityHelper <User> .InCollectionAsync(foundBoard.Users, user, "User is not assigned to this board!", false);

                foundBoard.Users.Remove(foundUser);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #16
0
        public async Task AddCommentToCardAsync(Card card, Comment comment)
        {
            try
            {
                var foundCard = await FindAndCheckNullabilityHelper <Card> .InDatabaseAsync(context.Cards, card, "Card not found!", false);

                var foundComment = await FindAndCheckNullabilityHelper <Comment> .InCollectionAsync(foundCard.Comments, comment, "Comment is already assigned to a card!", true);

                comment.Card = foundCard;
                context.Set <Comment>().Add(comment);
                //foundCard.Comments.Add(comment);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #17
0
        public async Task ChangeNameOfACardAsync(Card card, string newName)
        {
            try
            {
                var foundCard = await FindAndCheckNullabilityHelper <Card> .InDatabaseAsync(context.Cards, card, "Card not found!", false);

                if (foundCard.CardName.Equals(newName))
                {
                    throw new Exception("Names are the same!");
                }
                else
                {
                    context.Entry <Card>(foundCard).State = EntityState.Detached;
                    foundCard.CardName = newName;
                    context.Entry <Card>(foundCard).State = EntityState.Modified;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #18
0
        public async Task RenameBoardAsync(Board board, string newName)
        {
            try
            {
                var foundBoard = await FindAndCheckNullabilityHelper <Board> .InDatabaseAsync(context.Boards, board, "Board was not found!", false);

                if (foundBoard.Name.Equals(newName))
                {
                    throw new Exception("Names are equal!");
                }
                else
                {
                    context.Entry <Board>(foundBoard).State = EntityState.Detached;
                    foundBoard.Name = newName;
                    context.Entry <Board>(foundBoard).State = EntityState.Modified;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #19
0
 public async Task <T> FindEntityAsync(T entity)
 {
     return(await FindAndCheckNullabilityHelper <T> .FindEntityAsync(set, entity));
 }