public async Task <IActionResult> Delete(string userid, string downloadid)
        {
            if (userid == "@me")
            {
                userid = UserId;
            }

            var user = await _users.GetByIdAsync(userid);

            if (user == null)
            {
                return(NotFound(new ErrorResponse("The user does not exist.")));
            }

            var download = await _downloads.GetByIdAsync(downloadid);

            if (download == null)
            {
                return(NotFound(new ErrorResponse("The download does not exist.")));
            }

            await _downloads.RemoveAuthorAsync(downloadid, userid);

            return(NoContent());
        }
        public async Task <IActionResult> Get(string id)
        {
            var download = await _downloads.GetByIdAsync(id);

            if (download == null)
            {
                return(NotFound(new ErrorResponse("The download does not exist.")));
            }

            return(Ok(_mapper.Map <List <DownloadFileResponse> >(download.Files)));
        }
        protected override async Task <IEntityCollection <Application> > MapAsync(IEnumerable <Application> items)
        {
            foreach (var item in items)
            {
                item.Author = await _users.GetByIdAsync(item.UserId);

                item.Download = await _downloads.GetByIdAsync(item.DownloadId);
            }

            return(await base.MapAsync(items));
        }
示例#4
0
        public async Task <IActionResult> Download(string download, string filename)
        {
            Download dl = await _downloads.GetByIdAsync(download);

            if (dl.Visibility == DownloadVisibility.Private)
            {
                return(Redirect($"/downloads/{download}"));
            }

            DownloadFile file = (await _files.GetByDownloadAndFilenameAsync(download, filename)).First();

            return(Redirect(file.Url));
        }