public async Task <IActionResult> Create([Bind("Title,Description,File,LinkPath,TagIds")] Download download) { if (download.File == null) { ModelState.AddModelError(nameof(download.File), "The File field is required."); } else if (download.File.Length < 1) { ModelState.AddModelError(nameof(download.File), "Filesize too small"); } if (!ModelState.IsValid) { return(View(download)); } if (download.File != null) { download.LinkPath = await _uploadService.Upload(download.File, "/files", Path.GetFileNameWithoutExtension(download.File.FileName)); } download.DownloadTags = download.TagIds ?.Select(tagId => new DownloadTag { Download = download, TagId = tagId }).ToList(); download.Language = "nl"; download.LastModified = download.Date = DateTime.UtcNow; await _downloadRepository.Create(download); return(RedirectToAction(nameof(Index))); }