Beispiel #1
0
        public static async Task <HttpStatusCode> AddOrRemoveAlbumLikeAsync(
            ApplicationDbContext dbContext,
            string userId,
            int entryId,
            LikeRequest like)
        {
            MediaAlbum albumEntity = await dbContext.MediaAlbums
                                     .SingleOrDefaultAsync(te => te.MediaAlbumId == entryId);

            if (albumEntity == null)
            {
                // The entry id is part of the URL, so return a 404.
                return(HttpStatusCode.NotFound);
            }

            return(await LikeOperations.AddOrRemoveLikeAsync(
                       dbContext,
                       userId,
                       entryId,
                       le => le.MediaAlbumId,
                       like));
        }
Beispiel #2
0
        public static async Task <HttpStatusCode> AddOrRemoveCommentLikeAsync(
            ApplicationDbContext dbContext,
            string userId,
            int commentId,
            LikeRequest like)
        {
            Comment commentEntity = await dbContext.Comments
                                    .SingleOrDefaultAsync(c => c.CommentId == commentId);

            if (commentEntity == null)
            {
                // The entry id is part of the URL, so return a 404.
                return(HttpStatusCode.NotFound);
            }

            return(await LikeOperations.AddOrRemoveLikeAsync(
                       dbContext,
                       userId,
                       commentEntity.UserTextId,
                       l => l.UserTextId,
                       like));
        }
Beispiel #3
0
        public static async Task <HttpStatusCode> AddOrRemoveMediaLikeAsync(
            ApplicationDbContext dbContext,
            string userId,
            int mediaId,
            LikeRequest like)
        {
            UserMedia mediaEntity = await dbContext.UserMedias
                                    .SingleOrDefaultAsync(te => te.UserMediaId == mediaId);

            if (mediaEntity == null)
            {
                // The entry id is part of the URL, so return a 404.
                return(HttpStatusCode.NotFound);
            }

            return(await LikeOperations.AddOrRemoveLikeAsync(
                       dbContext,
                       userId,
                       mediaId,
                       le => le.UserMediaId,
                       like));
        }
Beispiel #4
0
        public static async Task <HttpStatusCode> AddOrRemoveTimelineEntryLikeAsync(
            ApplicationDbContext dbContext,
            string userId,
            int entryId,
            LikeRequest like)
        {
            TimelineEntry entryEntity = await dbContext.TimelineEntries
                                        .SingleOrDefaultAsync(te => te.TimelineEntryId == entryId);

            if (entryEntity == null)
            {
                // The entry id is part of the URL, so return a 404.
                return(HttpStatusCode.NotFound);
            }

            return(await LikeOperations.AddOrRemoveLikeAsync(
                       dbContext,
                       userId,
                       entryId,
                       le => le.UserTextId,
                       like));
        }