コード例 #1
0
        public async Task RunAsync(Request request, DateTime?deletionUtcDate = null)
        {
            await request.CheckValidityAsync(dbContext, localizer);

            foreach (var cardId in request.CardIds)
            {
                var previousVersionCreator = new PreviousVersionCreator(dbContext);
                var card = await previousVersionCreator.RunAsync(cardId, request.User, localizer["Deletion"].Value, deletionUtcDate);

                await previousVersionCreator.RunForDeletionAsync(card);

                dbContext.Cards.Remove(card);
            }

            await dbContext.SaveChangesAsync();
        }
コード例 #2
0
        public async Task RunAsync(Request request, IStringLocalizer localizer)
        {
            await request.CheckValidityAsync(localizer, dbContext);

            var previousVersionCreator = new PreviousVersionCreator(dbContext);
            var card = await previousVersionCreator.RunAsync(request.CardId, request.VersionCreator, request.VersionDescription);

            card.CardLanguage   = dbContext.CardLanguages.Where(language => language.Id == request.LanguageId).Single();
            card.FrontSide      = request.FrontSide;
            card.BackSide       = request.BackSide;
            card.AdditionalInfo = request.AdditionalInfo;
            await UpdateTagsAsync(request, card);
            await UpdateUsersWithViewAsync(request, card);
            await UpdateImagesAsync(request, card);

            await dbContext.SaveChangesAsync();
        }
コード例 #3
0
ファイル: AddTagToCards.cs プロジェクト: Malausinus/memcheck
        public async Task RunAsync(Request request)
        {
            await request.CheckValidityAsync(dbContext);

            var tagName = await dbContext.Tags.Where(tag => tag.Id == request.TagId).Select(tag => tag.Name).SingleAsync();

            var previousVersionCreator = new PreviousVersionCreator(dbContext);

            foreach (var cardId in request.CardIds)
            {
                if (!dbContext.TagsInCards.Any(tagInCard => tagInCard.CardId == cardId && tagInCard.TagId == request.TagId))
                {
                    var card = await previousVersionCreator.RunAsync(cardId, request.VersionCreator, localizer["AddTag"].Value + $" '{tagName}'");

                    card.VersionCreator = request.VersionCreator; //A priori inutile, à confirmer
                    dbContext.TagsInCards.Add(new TagInCard()
                    {
                        TagId = request.TagId, CardId = cardId
                    });
                }
            }
            await dbContext.SaveChangesAsync();
        }