Пример #1
0
        public async Task <FileDto> SaveErrorsAsync(string fileId, ExternalFileUpdateCommand command, string email)
        {
            var fileReciver = await _context.FileRecivers
                              .FirstOrDefaultAsync(x => x.FileId == fileId && x.Email == email);

            if (fileReciver == null)
            {
                return(null);
            }

            fileReciver.Errors = command.Errors;

            var file = await _context.Files.FirstOrDefaultAsync(x => fileId == x.Id);

            file.FileState = FileState.Rejected;

            await _context.SaveChangesAsync();

            return(await FindAsync(fileId, email));
        }
Пример #2
0
        public async Task <IActionResult> PostErrorsAsync(string id, string accessToken, [FromBody] ExternalFileUpdateCommand command)
        {
            var email = await GetEmailAsync(accessToken);

            if (string.IsNullOrEmpty(email))
            {
                return(Unauthorized());
            }

            var file = await _externalFileService.SaveErrorsAsync(id, command, email);

            if (file == null)
            {
                return(NotFound());
            }

            return(Ok(file));
        }