public ActionResult Project3DModelPartial(Project3DModelViewModel model) { if (ModelState.IsValid) { var project = db.EventProjects.Find(model.EventProjectId); if (project == null) { return(HttpNotFound()); } if (model.ThreeDModelFile != null && model.ThreeDModelFile.ContentLength > 0) { var extensions = new[] { "pdf", "docx", "doc", "jpg", "jpeg", "png" }; string filename = Path.GetFileName(model.ThreeDModelFile.FileName); string ext = Path.GetExtension(filename).Substring(1); if (!extensions.Contains(ext, StringComparer.OrdinalIgnoreCase)) { ModelState.AddModelError(string.Empty, "Accepted file are pdf, docx, doc, jpg, jpeg, and png documents"); //return PartialView(); //ViewBag.extensionError = "Accepted file are pdf, docx, doc, jpg, jpeg, and png documents"; return(RedirectToAction("DetailsMaster", "EventProject", new { id = model.EventProjectId })); } string appFolder = "~/Content/Uploads/"; var rand = Guid.NewGuid().ToString(); string path = Path.Combine(Server.MapPath(appFolder), rand + "-" + filename); model.ThreeDModelFile.SaveAs(path); project.ThreeDModel = appFolder + rand + "-" + filename; } else { ModelState.AddModelError(string.Empty, "Empty files are not accepted"); //return PartialView(); //ViewBag.emptyError = "Empty files are not accepted"; return(RedirectToAction("DetailsMaster", "EventProject", new { id = model.EventProjectId })); } db.SaveChanges(); } //return PartialView(model); return(RedirectToAction("DetailsMaster", "EventProject", new { id = model.EventProjectId })); }
/// <summary> /// This action retrieves the 3D model added /// </summary> /// <param name="id">project id</param> /// <returns>Get 3D model partial view</returns> public ActionResult ProjectGet3DModelPartial(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var project = db.EventProjects.Find(id); if (project == null) { return(HttpNotFound()); } var model = new Project3DModelViewModel { EventProjectId = project.EventProjectId, ThreeDModel = project.ThreeDModel, }; return(PartialView(model)); }