示例#1
0
        public async Task <ActionResult <GroupPlaylistRatingDownloadModel> > EditGroupPlaylistRatingAsync(
            GroupPlaylistRatingUploadModel groupPlaylistRatingUploadModel)
        {
            try
            {
                if (await IsUserValidAsync())
                {
                    var groupPlaylistRating = await GroupPlaylistRatingModel.EditGroupPlaylistRatingAsync(
                        groupPlaylistRatingUploadModel.GroupPlaylistRatingId,
                        groupPlaylistRatingUploadModel,
                        ExtractUserIdFromToken(),
                        RepositoryManager);

                    return(Ok(MapEntityToDownloadModel <GroupPlaylistRating, GroupPlaylistRatingDownloadModel>(groupPlaylistRating)));
                }
                else
                {
                    return(Unauthorized());
                }
            }
            catch (UserForbiddenException)
            {
                return(Forbid());
            }
            catch (InvalidTokenException err)
            {
                return(BadRequest(new InvalidTokenException(err.InvalidTokenType, err.ErrorMessage)));
            }
            catch (Exception err)
            {
                LogException(err);

                return(Problem());
            }
        }
示例#2
0
        public async Task <ActionResult <GroupPlaylistRatingDownloadModel> > DeleteGroupPlaylistAsync(Guid groupPlaylistRatingId)
        {
            try
            {
                if (await IsUserValidAsync())
                {
                    await GroupPlaylistRatingModel.DeleteGroupPlaylistRatingAsync(
                        groupPlaylistRatingId,
                        ExtractUserIdFromToken(),
                        RepositoryManager);

                    return(Ok());
                }
                else
                {
                    return(Unauthorized());
                }
            }
            catch (UserForbiddenException)
            {
                return(Forbid());
            }
            catch (InvalidTokenException err)
            {
                return(BadRequest(new InvalidTokenException(err.InvalidTokenType, err.ErrorMessage)));
            }
            catch (Exception err)
            {
                LogException(err);

                return(Problem());
            }
        }