public async Task <IActionResult> InsertFile(FileViewModel fileViewModel) { var fileName = await _fileStoreService.AddAsync(fileViewModel.File.FileName, fileViewModel.File.OpenReadStream()); var document = _mapper.Map <Document>(fileViewModel); var documentType = DocumentEnum.FindBy(document.Type); document.Type = documentType.Id; if (documentType.Id == DocumentEnum.EXTERNAL.Id) { document.ExternalFile = new ExternalFile { Path = fileName }; } if (documentType.Id == DocumentEnum.INTERNAL.Id) { document.InternalFile = new InternalFile { Path = fileName }; } await _documentService.CreateAsync(document); return(ResponseHelper.Ok(document)); }