Exemplo n.º 1
0
        public async Task <ActionResult <FileCommon> > UploadFile([FromBody] FileCommon file)
        {
            file.UserId = this.UserId();
            var uploadedFile = await _fileService.UploadFile(file.ToDB());

            return(new JsonResult(uploadedFile));
        }
Exemplo n.º 2
0
        public async Task <FileCommon> UploadFile(FileCommon file)
        {
            var fileDb = file.ToDB();

            fileDb.UserName   = (await _userRepository.Get(file.UserId)).Username;
            fileDb.UploadDate = DateTime.UtcNow;
            var uploadedFileId = await _fileRepository.UploadFile(fileDb);

            return((await _fileRepository.GetWhere(f => f.Id == uploadedFileId)).First().ToCommon());
        }