Exemplo n.º 1
0
        // GET: WoodProjects/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            WoodProject woodProject = db.WoodProjects.Find(id);

            if (woodProject == null)
            {
                return(HttpNotFound());
            }
            return(View(woodProject));
        }
Exemplo n.º 2
0
        public ActionResult DeleteConfirmed(int id)
        {
            WoodProject woodProject = db.WoodProjects.Find(id);
            var         result      = db.ImageFiles.Where(x => x.WoodProject.Id == id);

            db.WoodProjects.Remove(woodProject);

            foreach (var image in result)
            {
                db.ImageFiles.Remove(image);
            }
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 3
0
    private void CreateWoodProject(GameObject initialPiece)
    {
        connectedProject     = new GameObject("Wood Project");
        connectedProject.tag = "WoodProject";
        connectedProject.transform.position = ProjectCenter.position;

        initialPiece.SetActive(true);
        initialPiece.GetComponent <SnapPiece>().SnapToProject(connectedProject.transform);

        SnapPiece   snapPiece       = connectedProject.AddComponent <SnapPiece>();
        WoodProject woodProjectComp = connectedProject.AddComponent <WoodProject>();

        woodProjectComp.AddPieceToProject(initialPiece);

        GluedPieceController controller = connectedProject.AddComponent <GluedPieceController>();
    }
Exemplo n.º 4
0
        public ActionResult Create([Bind(Include = "ID,ProjectTitle,ImageURL,Description,ProjectType")] WoodProject woodProject, string projectType, HttpPostedFileBase[] files)
        {
            try
            {
                ViewBag.ProjectTypes = new SelectList(new WoodProject().ProjectTypes);

                if (ModelState.IsValid)
                {
                    woodProject.ProjectType = projectType;
                    foreach (HttpPostedFileBase file in files)
                    {
                        var imageFile = new ImageFile();
                        if (file.ContentLength > 0)
                        {
                            //TODO: Check for same filename and change file path if needed
                            var fileName = Path.GetFileName(file.FileName);
                            var path     = Path.Combine(Server.MapPath("~/Content/Wood_Project_Images"), fileName);

                            //REMOVE THIS
                            woodProject.ImageURL = path.Substring(path.IndexOf("Content"));

                            imageFile.WoodProject = woodProject;
                            imageFile.Directory   = path.Substring(path.IndexOf("Content"));

                            db.ImageFiles.Add(imageFile);
                            file.SaveAs(path);
                        }
                    }


                    var user = User.Identity.GetUserId();
                    woodProject.UserId      = user;
                    woodProject.PublishDate = DateTime.Now;
                    db.WoodProjects.Add(woodProject);

                    db.SaveChanges();
                }
            } catch (RetryLimitExceededException dex)
            {
                //Can log dex exception here
                ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator.");
                return(View("Error", new HandleErrorInfo(dex, "WoodProject", "Index")));
            }

            return(RedirectToAction("Index"));
        }
Exemplo n.º 5
0
 public ActionResult Edit([Bind(Include = "ID,ProjectTitle,ImageURL,Description,PublishDate,ProjectType")] WoodProject woodProject)
 {
     try
     {
         if (ModelState.IsValid)
         {
             db.Entry(woodProject).State = EntityState.Modified;
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
         return(View(woodProject));
     }
     catch (RetryLimitExceededException dex)
     {
         //Can log dex exception here
         ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator.");
         return(View("Error", new HandleErrorInfo(dex, "WoodProject", "Index")));
     }
 }
Exemplo n.º 6
0
 public void CreateGluingButton(WoodProject project, GlueManager manager)
 {
     GluingButtonList.CreateButton(null, project.name, manager);
 }