public async Task <IActionResult> AddDocument([FromForm] IFormFile file, string fileName, int workspaceId, string sectionName) { if (file == null || string.IsNullOrWhiteSpace(fileName) || string.IsNullOrWhiteSpace(sectionName)) { return(RedirectToAction("Workspace", new { id = workspaceId, returnMessage = "F Fields cannot be blank" })); } var workspace = await _workspaceRepository.GetByIdAsync(workspaceId); if (User.FindFirst(Constants.SuperAdminClaim) is not null || User.HasClaim(x => x.Type == Constants.AdminClaim && x.Value == workspace.Guid.ToString())) { var section = workspace.Sections.FirstOrDefault(x => x.Name == sectionName); string fileExtension = Path.GetExtension(file.FileName); string storedFileName = await _storageService.SaveFile(file, fileExtension); var document = new Document { Name = fileName, Section = section, FileContentType = file.ContentType, FileExtension = fileExtension, FileName = storedFileName, TimePosted = DateTime.UtcNow }; await _documentRepository.CreateAsync(document); return(RedirectToAction("Workspace", new { id = workspaceId, activeOnly = true, returnMessage = "S Document Added!" })); } return(Unauthorized()); }