public ActionResult Manage(ManageArtifactViewModel manageArtifactViewModel) { UserCheck(); DateTime publishDate = DateTime.Parse(manageArtifactViewModel.PublishDate); User currentUser = (User)Session[Constants.CURRENT_USER]; HttpPostedFileBase file = null; foreach (string fileName in Request.Files) { file = Request.Files[fileName]; } Artifact artifact; if (manageArtifactViewModel.ArtifactId != null) { artifact = artifactService.FindArtifactById(manageArtifactViewModel.ArtifactId.Value, false); artifact = artifactService.AddContentToArtifact(artifact, file, manageArtifactViewModel.ContentHtml, publishDate, currentUser); } else { if (file == null) { artifact = artifactService.CreateArtifactFromContent(manageArtifactViewModel.Name, manageArtifactViewModel.Description, manageArtifactViewModel.ContentHtml, publishDate, currentUser); } else { artifact = artifactService.CreateArtifactFromFile(manageArtifactViewModel.Name, manageArtifactViewModel.Description, file, publishDate, currentUser); } } // Model has been updated, update ViewModel. manageArtifactViewModel = ConvertArtifactToViewModel(artifact); return(View("ManageArtifact", manageArtifactViewModel)); }