//Ok public void Create(FileDTO item) { _data.Files.Create(Mapper.Map <UserFile>(item)); File.WriteAllBytes(ReturnFullPath(item), item.FileBytes); _data.Save(); }
public async void Download(FileDTO file) { var directory = "Downloads"; if (!Directory.Exists(directory)) { Directory.CreateDirectory(directory); } var destination = Path.Combine(directory, $"{file.Id.ToString()}{Path.GetExtension(file.Name)}"); for (int part = 1; part <= file.Parts; part++) { var filePartResponse = await _httpManager.GetAsync <FilePartDTO>($"api/Files/{file.Id}/DownloadPart/{part}"); if (filePartResponse.Error != null) { Failed?.Invoke(filePartResponse.Error.ErrorDescription); return; } using (var fs = new FileStream(destination, FileMode.Append, FileAccess.Write, FileShare.Write)) { fs.Write(filePartResponse.Data.Content, 0, filePartResponse.Data.Content.Length); //fs.BeginWrite( // filePartResponse.Data.Content, // 0, // filePartResponse.Data.Content.Length, // new AsyncCallback((a) => { PartDownloaded(part); }), // null); PartDownloaded(part); } } }
public bool WriteRecordsToFile(FileDTO lstRows, string originalFileName, string format, string folder) { try { var config = new Configuration(); if (format == "TAB") { config.Delimiter = "\t"; } ; config.HasHeaderRecord = false; string fileName = originalFileName; string validPath = Path.Combine(HttpContext.Current.Server.MapPath("~/" + folder), fileName); using (var writer = new StreamWriter(validPath)) using (var csv = new CsvWriter(writer, config)) { csv.WriteRecords(lstRows.Rows); } return(true); } catch (Exception ex) { return(false); } }
public string Delete(int id) { if (_db.Files.Any(x => x.Id == id)) { FileDTO travel = _db.Files.Where(x => x.Id == id).Include(x => x.Hike).First(); var rootDir = _environment.ContentRootPath; var imagesDir = rootDir + "\\wwwroot\\Hikes\\Files\\"; var hikeDir = imagesDir + "\\Hike_" + travel.Hike.Id; if (Directory.Exists(hikeDir)) { if (System.IO.File.Exists(hikeDir + travel.FileName)) { System.IO.File.Delete(hikeDir + travel.FileName); } } _db.Files.Remove(travel); _db.SaveChanges(); return("OK"); } return("ERR"); }
public IActionResult UploadFile() { HttpRequest request = HttpContext.Request; if (request.Form.Files.Count <= 0) { return(BadRequest("File was not found. Please upload it.")); } var file = request.Form.Files["File"]; if (file?.Length <= 0) { return(BadRequest("File have not content")); } FileDTO fileDto = new FileDTO { AccessLevel = Convert.ToBoolean(request.Form["AccessLevel"]), Name = file.FileName, FolderId = Convert.ToInt32(request.Form["FolderId"]) }; if (_fileService.IsFileExists(fileDto)) { return(BadRequest("The file with the specified name exists. Please change the file name")); } file.OpenReadStream().Read(fileDto.FileBytes = new byte[file.Length], 0, (int)file.Length); if (!_folderService.CanAdd(User.Identity.Name, fileDto.FileBytes.Length)) { return(BadRequest("You did not have memory to add the file")); } _fileService.Create(fileDto); return(Ok()); }
public async Task OnGetAsync() { var files = await fpc.GetAllFilesAsync(); foreach (var item in files) { FileDTO fd = new FileDTO(); fd.Id = item.Id; fd.Path = item.Path; fd.Name = item.Name; fd.Properties = new List <PropertyDTO>(); var properties = await fpc.GetPropertiesByFileIdAsync(item.Id); foreach (var prop in properties) { PropertyDTO propd = new PropertyDTO(); propd.Id = prop.Id; propd.Key = prop.Key; propd.Value = prop.Value; fd.Properties.Add(propd); } Files.Add(fd); } }
public async Task OnGetAsync(int?id, string sortOrder) { if (!id.HasValue) { return; } var items = await client.GetFilesByFolderIdAsync(id.Value); switch (sortOrder) { case "Name": foreach (var cc in items) { FileDTO files = new FileDTO(); files.FolderId = cc.FolderId; files.FileName = cc.FileName; files.FileDesc = cc.FileDesc; files.FilePath = cc.FilePath; files.FileTags = cc.FileTags; files.FileDate = cc.FileDate; Files.Add(files); } break; default: items.OrderBy(s => s.FileID); break; } }
public async Task <IActionResult> ImportData(FileDTO fileDto) { try { if (!ModelState.IsValid) { string messages = string.Join("; ", ModelState.Values .SelectMany(x => x.Errors) .Select(x => x.ErrorMessage)); throw new Exception("Please correct the following errors: " + Environment.NewLine + messages); } //Upload the Excel Spreadsheet of learners var path = _fileService.UploadFile(fileDto.File, _foldersConfigation.Uploads); //import the data if (path != null) { await _dataService.ImportExcelForLearners(path); _notyf.Success("File uploaded successfully..."); } else { _notyf.Error("Invalid file uploaded"); return(Json(new { Result = "ERROR", Message = "Invalid file uploaded" })); } return(Json(new { Result = "OK" })); } catch (Exception ex) { _notyf.Error("Something went wrong : " + ex.Message); return(Json(new { Result = "ERROR", Message = ex.Message })); } }
public HttpResponseMessage UpdateResourcesForHomeworkinModules(int id, FileDTO fileDto) { try { //sterg fosta resursa string nameOfFile = this._homeworkManagement.GetNameOfFile(id); this._resourcesManagement.DeleteHomeworkResource(nameOfFile); //fac upload cu noua resursa var directoryFather = _resourcesManagement.GetFileIdForAModule(fileDto.parentId); var result = this._resourcesManagement.UploadFile(fileDto.filePath, directoryFather); Resources resources = new Resources { ResourceType = ResourceEnum.File.ToString(), FileLocation = "", FileId = result.Id, FileName = fileDto.fileName, CourseId = fileDto.rootId, ModuleID = fileDto.parentId }; this._resourcesManagement.SaveResourcesToDb(resources); return(Request.CreateResponse(HttpStatusCode.OK)); } catch (Exception) { // Log exception code goes here return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Error occured while executing method.")); } }
public async Task Test_GetExample() { //Arrange. FileDTO fileDownload = new FileDTO() { Name = "EXAMPLE.txt", ContentType = "text/plain", Extension = "txt", Content = new MemoryStream(new byte[] { 125, 141, 13, 27 }) }; this._raceServiceMock .Setup(srv => srv.GetExampleFileAsync()) .Returns(Task.FromResult(fileDownload)); //Act. var result = await this._racesController.GetExample(); //Assert. Assert.IsInstanceOfType(result, typeof(FileStreamResult)); var resultFile = result as FileStreamResult; Assert.AreEqual(fileDownload.Name, resultFile.FileDownloadName); Assert.AreEqual(fileDownload.ContentType, resultFile.ContentType); Assert.AreEqual(fileDownload.Content, resultFile.FileStream); }
public HttpResponseMessage UploadResourcesForHomework(int id, FileDTO fileDto) { try { var directoryFather = _resourcesManagement.GetFileIdForADirectory(id); var result = this._resourcesManagement.UploadFile(fileDto.filePath, directoryFather); Resources resources = new Resources { ResourceType = ResourceEnum.File.ToString(), FileLocation = "", FileId = result.Id, FileName = fileDto.fileName, CourseId = fileDto.parentId, ModuleID = -1 }; this._resourcesManagement.SaveResourcesToDb(resources); return(Request.CreateResponse(HttpStatusCode.OK)); } catch (Exception) { // Log exception code goes here return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Error occured while executing method.")); } }
public void GetSubDirectoryAndFiles(FileDTO dt, string id) { DirectoryInfo di = new DirectoryInfo(dt.FileName); var SubFilesOrderby = di.GetDirectories().OrderBy(x => x.FullName).ToList(); foreach (var subDi in SubFilesOrderby) { FileDTO subDt = new FileDTO(); subDt.ID = Guid.NewGuid(); subDt.FileName = subDi.FullName; subDt.Name = subDi.Name; subDt.Extension = subDi.Extension; if (("C:\\inetpub\\intranet\\files\\" + id).Contains(subDt.FileName)) { subDt.Expand = true; } else { subDt.Expand = false; } dt.Directories.Add(subDt); GetSubDirectoryAndFiles(subDt, id); } foreach (FileInfo fi in di.GetFiles()) { FileDTO subDt = new FileDTO(); subDt.ID = Guid.NewGuid(); subDt.FileName = fi.FullName; subDt.Name = fi.Name; subDt.Extension = fi.Extension; dt.Files.Add(subDt); } }
public async Task OnGetAsync() { MockData data = new MockData(); //var allProperties = await client.GetAllPropertiesAsync(); var allProperties = data.GetAllProperties(); SearchableProperties = new List <string>(); foreach (Property p in allProperties) { SearchableProperties.Add(p.Title); } FilterPropertyList = new SelectList(SearchableProperties); //var allFiles = await client.GetAllFilesAsync(); List <File> allFiles = data.GetAllFiles(); foreach (File file in allFiles) { FileDTO fileDTO = new FileDTO(file); List <Property> propertiesOfFile = data.GetAllPropertiesForFileId(file.Id); if (!string.IsNullOrEmpty(SearchString)) { if (propertiesOfFile.Find(p => p.Title.Equals(SearchString)) != null) { Files.Add(fileDTO); } } else { Files.Add(fileDTO); } } SearchResults = Files.Count; }
public async Task Create(CreateUserRequestModel model) { await new CreateUserValidator().ValidateRequestModelAndThrow(model); User user = new User(model.Name, model.Email, model.Password); await ThrowIfUserNameAlreadyExists(user.Name); await ThrowIfUserEmailAlreadyExists(user.Email); user.UpdateConfirmationCode(_randomCodeUtils.GenerateRandomCode()); user.UpdatePassword(_hashUtils.GenerateHash(user.Password)); Stream userDefaultProfileImage = _fileUploadUtils.GetDefaultUserProfileImage(); FileDTO uploadedProfileImage = await _fileUploadUtils.UploadImage(userDefaultProfileImage); ProfileImage image = new ProfileImage(uploadedProfileImage.FileName, uploadedProfileImage.FilePath); user.AddProfileImage(image); await _userRepository.Create(user); await _userRepository.Save(); await _emailUtils.SendEmail(user.Email, "Confirmation", $"Please confirm your account using this code {user.ConfirmationCode}"); }
private HttpResponseMessage DownloadFile(FileDTO fileDto) { try { var appPhysicalPath = System.Web.HttpContext.Current.Server.MapPath("~/UploadedFiles"); HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK); var fileFullPath = System.IO.Path.Combine(appPhysicalPath, fileDto.UniqueName + fileDto.Extension); byte[] file = System.IO.File.ReadAllBytes(fileFullPath); System.IO.MemoryStream ms = new System.IO.MemoryStream(file); response.Content = new ByteArrayContent(file); response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment"); //String mimeType = MimeType.GetMimeType(file); //You may do your hard coding here based on file extension response.Content.Headers.ContentType = new MediaTypeHeaderValue(fileDto.ContentType); response.Content.Headers.ContentDisposition.FileName = fileDto.ActualFileName; return(response); } catch (Exception ex) { Utility.HandleException(ex); HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.NotFound); return(response); } }
public Object GenerateThumbnail(string uniqueName) { var rootPath = HttpContext.Current.Server.MapPath("~/UploadedFiles"); FileDTO dto = (FileDTO)Drive.BAL.FileBO.GetFileByUniqueName(uniqueName); if (dto != null) { HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK); var fileFullPath = Path.Combine(rootPath, dto.UniqueName + dto.FileExt); ShellFile shellFile = ShellFile.FromFilePath(fileFullPath); Bitmap shellThumb = shellFile.Thumbnail.LargeBitmap; byte[] file = ImageToBytes(shellThumb); MemoryStream ms = new MemoryStream(file); response.Content = new ByteArrayContent(file); response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment"); response.Content.Headers.ContentType = new MediaTypeHeaderValue(dto.ContentType); response.Content.Headers.ContentDisposition.FileName = dto.Name; return(response); } else { HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.NotFound); return(response); } }
public ActionResult saveFile() { if (Request.Files["file"] != null) { var uniqueName = ""; FileDTO f = new FileDTO(); var file = Request.Files["file"]; if (file.FileName != "") { var ext = System.IO.Path.GetExtension(file.FileName); f.fileExt = ext; f.fileSizeInKb = file.ContentLength / 1000; f.uploadedOn = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"); f.IsActive = true; f.parentFolderId = Convert.ToInt32(Session["pid"]); uniqueName = Guid.NewGuid().ToString() + ext; f.fileName = uniqueName; var rootPath = Server.MapPath("~/UploadedFiles"); var fileSavePath = System.IO.Path.Combine(rootPath, uniqueName); file.SaveAs(fileSavePath); // Session["image"] = uniqueName; } FileDAO.Save(f); } return(Redirect("~/Users/Folder")); }
public HttpResponseMessage UpdateResourcesForModule(int id, FileDTO dto) { try { //delete old resource var directoryFather = _resourcesManagement.GetFileIdForAModule(dto.parentId); this._resourcesManagement.DeleteModuleResource(id); //add new resource var result = this._resourcesManagement.UploadFile(dto.filePath, directoryFather); Resources resources = new Resources { ResourceType = ResourceEnum.File.ToString(), FileLocation = "", FileId = result.Id, FileName = dto.fileName, //result.Title, CourseId = dto.rootId, // sau -1? mai vedem ModuleID = dto.parentId }; this._resourcesManagement.SaveResourcesToDb(resources); return(Request.CreateResponse(HttpStatusCode.OK)); } catch (Exception) { // Log exception code goes here return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Error occured while executing method.")); } }
public IActionResult Create(FileDTO file) { string path = FileManager.IFormSave(file.File, "temp"); string id = _cloudinary.Store(path); File newFile = new File { FilePath = id, FileName = file.File.Name }; _fileService.Create(newFile); object data = new { senderEmail = file.From, fileCount = "1", fileSize = file.File.Length / 1000000, date = DateTime.UtcNow.ToString("dd-MM-yyyy"), message = file.Message }; _emailService.Send(file.To, "SenderMan", "d-489e8c077adb4797be48273d349760cf", data); return(RedirectToAction("index")); }
public Object downLoadFile(int fileId) { FileDTO fileDTO = BAL.FileBO.getFileById(fileId); String rootPath = HttpContext.Current.Server.MapPath("~/UploadedFiles"); if (fileDTO != null) { HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK); var fileFullPath = System.IO.Path.Combine(rootPath, fileDTO.UniqName); byte[] file = System.IO.File.ReadAllBytes(fileFullPath); System.IO.MemoryStream ms = new System.IO.MemoryStream(file); response.Content = new ByteArrayContent(file); response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment"); // String mimeType = //response.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue ( fileDTO.FileExt ); response.Content.Headers.ContentDisposition.FileName = fileDTO.Name + fileDTO.FileExt; return(response); } else { HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.NotFound); return(response); } }
public Object DownloadFile(String uniqueName) { HttpContext.Current.Response.AppendHeader("Access-Control-Allow-Origin", "*"); //Physical Path of Root Folder string rootPath = System.Web.HttpContext.Current.Server.MapPath("~/UploadedFiles"); FileModel.GetFilesInPath(rootPath); //Find File from DB against unique name FileDTO fileDTO = FileModel.GetFileByUniqueID(uniqueName); if (fileDTO != null) { HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK); var fileFullPath = System.IO.Path.Combine(rootPath, fileDTO.FileUniqueName + fileDTO.FileExt); byte[] file = System.IO.File.ReadAllBytes(fileFullPath); System.IO.MemoryStream ms = new System.IO.MemoryStream(file); response.Content = new ByteArrayContent(file); response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment"); //String mimeType = MimeType.GetMimeType(file); //You may do your hard coding here based on file extension response.Content.Headers.ContentType = new MediaTypeHeaderValue(fileDTO.ContentType);// obj.DocumentName.Substring(obj.DocumentName.LastIndexOf(".") + 1, 3); response.Content.Headers.ContentDisposition.FileName = fileDTO.FileActualName + fileDTO.FileExt; return(response); } else { HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.NotFound); return(response); } }
public async Task <RaceResultDTO> AnalyseAsync(CreateRaceDTO createData, FileDTO file, string uploader) { //Validar minimamente os dados de input. if (createData == null || file == null || uploader == null) { throw new BusinessException("Dados inválidos para análise"); } else if (!this.ValidateRequiredFields(createData, file, out string requiredFieldsErrorMessage)) { throw new BusinessException(requiredFieldsErrorMessage); } //Processar o arquivo. await this._raceFileReader.Read(file.Content); //Tratar retorno. if (this.ValidatePostProcessing(out string postProcessingErrorMessage)) { int newRaceId = await this.ProcessAndSaveData(createData, uploader, this._raceFileReader.Results); return(await this.GetResultByIdAsync(newRaceId)); } else { throw new BusinessException(postProcessingErrorMessage); } }
/// <summary> /// 上传到图片服务器 /// </summary> /// <param name="realPath">文件全路径</param> /// <returns></returns> private string UploadFile(string realPath) { var imageUrl = string.Empty; if (File.Exists(realPath)) { using (FileStream stream = new FileStream(realPath, FileMode.Open)) { int fileLength = Convert.ToInt32(stream.Length); FileDTO file = new FileDTO(); file.UploadFileName = Path.GetFileName(realPath); byte[] fileData = new byte[fileLength]; stream.Read(fileData, 0, fileLength); file.FileData = fileData; file.FileSize = fileData.Length; file.StartPosition = 0; file.IsClient = false; //上传文件获得url imageUrl = BTPFileSV.Instance.UploadFile(file); if (!string.IsNullOrEmpty(imageUrl)) //上传成功 { imageUrl = CustomConfig.FileServerUrl + imageUrl; } } } return(imageUrl); }
public bool CheckFile(FileDTO fileDTO) { if (fileDTO.Size > MaxSize) { return(false); } return(CheckType(fileDTO.Type)); }
public IHttpActionResult Photo(FileDTO fileDTO) { if (!UsersData.updatePhoto(fileDTO)) { return(BadRequest()); } return(Ok()); }
public IHttpActionResult File(FileDTO fileDTO) { if (!UsersData.postFile(fileDTO)) { return(BadRequest()); } return(Ok()); }
private FileModel FormFileModel(FileDTO file, System.IO.Stream stream) { return(new FileModel { FileName = file.FileName, Stream = stream }); }
private string GenerateContent(FileDTO file) { var status = file.Parts == file.PartsUploaded ? "Loaded" : "Loading"; return($"Sharing a file - {file.Name}" + $"\n{status}- {file.PartsUploaded * 100 / file.Parts}%" + $"\nSize - {file.Size} bytes"); }
public async Task <List <string> > CreateMove(FileDTO file) { var moveDetails = await this.moveRepository.CreateMove(file); List <MoveDetailDTO> list = _mapperDependency.Map <List <MoveDetailDTO> >(moveDetails.ToList()); return(GetMovingGrips(list)); }
public void UploadFile() { HttpContext.Current.Response.AppendHeader("Access-Control-Allow-Origin", "*"); if (HttpContext.Current.Request.Files.Count > 0) { try { foreach (var fileName in HttpContext.Current.Request.Files.AllKeys) { HttpPostedFile file = HttpContext.Current.Request.Files[fileName]; if (file != null) { FileDTO fileDTO = new FileDTO(); fileDTO.FileActualName = file.FileName; fileDTO.FileExt = Path.GetExtension(file.FileName); fileDTO.ContentType = file.ContentType; //Generate a unique name using Guid //fileDTO.FileUniqueName = Guid.NewGuid().ToString(); DateTime dateTime = new DateTime(); string fileUniqueNameExt = file.FileName.Replace(".", " " + dateTime.ToString().Replace('.', '_').Replace(':', '_') + "."); fileDTO.FileUniqueName = fileUniqueNameExt.Substring(0, fileUniqueNameExt.LastIndexOf('.')); //Get physical path of our folder where we want to save images //string rootPath = HttpContext.Current.Server.MapPath("~/UploadedFiles"); string rootPath = AppDomain.CurrentDomain.BaseDirectory; // You get main rott //string rootPath = Directory.GetCurrentDirectory(); string safePath; if (Directory.Exists(rootPath + "\\UploadedFiles")) { safePath = rootPath + "\\UploadedFiles"; } else { Directory.CreateDirectory(rootPath + "\\UploadedFiles"); safePath = rootPath + "\\UploadedFiles"; } var fileSavePath = System.IO.Path.Combine(safePath, fileDTO.FileUniqueName + fileDTO.FileExt); // Save the uploaded file to "UploadedFiles" folder file.SaveAs(fileSavePath); //Save File Meta data in Database FileModel.SaveFileInDB(fileDTO); } } } catch (Exception ex) { Console.WriteLine(ex.ToString()); HttpContext.Current.Response.Write("<h3>" + ex.ToString() + "</h3>"); } } var infoFile = HttpContext.Current.Request["infoFile"]; }
/// <summary> /// Gets a single row of file. /// </summary> /// <param name="fileName">The file name.</param> /// <returns>A instance of the FileDTO.</returns> public FileDTO GetFile(string fileName) { FileDTO result = null; fileName = fileName.Replace(GlobalStringResource.Data_DGXExtension, GlobalStringResource.WMFExtension); IDataReader reader = db.ExecuteReader(CommandType.Text, string.Format(GlobalStringResource.Data_GetFileQuery, fileName)); while (reader.Read()) { result = new FileDTO(); result.Data = (byte[])reader.GetValue(0); result.Date = reader.GetDateTime(1); result.Name = reader.IsDBNull(2) ? string.Empty : reader.GetString(2); result.Type = reader.IsDBNull(3) ? string.Empty : reader.GetString(3); } reader.Close(); reader.Dispose(); return result; }
public ActionResult CreateNewPrivateSnippet(CreateSnippetModelPrivate inModel) { UserDTO user = GetCurrentUserData(); var model = new CreateSnippetModel(_displayLanguages); if (ModelState.IsValid) { try { var newSnippet = new SnippetDTO { Guid = Guid.NewGuid(), Name = inModel.Name, Description = inModel.Description, Data = Encoding.UTF8.GetBytes(inModel.Data), IsPublic = false, Language_Id = inModel.LanguageId, LastModified = DateTime.UtcNow, User_Id = user.Id, User_FormsAuthId = user.FormsAuthId }; var files = new List<FileDTO>(); if (CurrentSnippet.UploadModel.Files.Any()) { for (int i = 0; i < CurrentSnippet.UploadModel.Files.Count(); i++) { NamedFileWithDescription file = ((List<NamedFileWithDescription>)CurrentSnippet.UploadModel.Files)[i]; var temp = new FileDTO { Name = file.Name, Description = file.Description, Data = file.File.Data, LastModified = DateTime.UtcNow }; files.Add(temp); } } // The new Guid and snippet id should be returned to us newSnippet = _managerService.CreateSnippet( newSnippet, new LanguageDTO { Id = inModel.LanguageId }, user, files.ToArray(), CurrentSnippet.Hyperlinks.ToArray()); var detailsModel = new SnippetDetailsModel { UserId = user.Id, UserGuid = user.FormsAuthId, UserName = user.LoginName, UserAvatar = user.AvatarImage, PreviewData = Encoding.UTF8.GetString(newSnippet.PreviewData), Data = Encoding.UTF8.GetString(newSnippet.Data), Name = newSnippet.Name, Description = newSnippet.Description, IsPublic = inModel.IsPublic, SnippetId = newSnippet.Guid, SnippetUrl = newSnippet.Guid.ToString(), Languages = _displayLanguages, Files = CurrentSnippet.UploadModel.Files ?? new List<NamedFileWithDescription>(), Hyperlinks = CurrentSnippet.Hyperlinks ?? new List<HyperlinkDTO>(), LanguageId = inModel.LanguageId }; UploadedFiles = null; CurrentSnippet.Hyperlinks = null; TempData["Message"] = "Saved Snippet Id: " + newSnippet.Guid + " Successfully"; return PartialView("_SnippetDetailsTablePartial", detailsModel); } catch (Exception ex) { Logger.LogError("CreateNewSnippet action method failed", ex); if (inModel.Languages == null) inModel.Languages = _displayLanguages; if (inModel.Hyperlinks == null) inModel.Hyperlinks = CurrentSnippet.Hyperlinks; if (inModel.UploadModel == null) inModel.UploadModel = CurrentSnippet.UploadModel; TempData["Error"] = "Unknown error occurred."; return View(inModel); } } else { inModel.Languages = _displayLanguages; TempData["Error"] = "Please fix any errors to continue"; return View(inModel); } }