Beispiel #1
0
        //
        // GET: /Admin/Plans/Delete/5

        public ActionResult Delete(int id)
        {
            project_plan project_plan = db.project_plan.Single(p => p.PlanID == id);

            ViewBag.Project = db.projects.FirstOrDefault(x => x.ProjectID == project_plan.ProjectID);
            return(View(project_plan));
        }
        public ActionResult PlanDown(int id)
        {
            //get the data
            var item  = db.project_plan.FirstOrDefault(x => x.PlanID == id);
            var items = db.project_plan.Where(x => x.ProjectID == item.ProjectID).OrderByDescending("Order");

            project_plan otheritem = null;

            foreach (var updateContent in items)
            {
                if (updateContent.PlanID == id)
                {
                    break;
                }
                otheritem = updateContent;
            }

            if (otheritem != null && otheritem.PlanID != otheritem.PlanID)
            {
                int oldorder = item.Order;
                item.Order      = otheritem.Order;
                otheritem.Order = oldorder;
                db.SaveChanges();
            }

            return(RedirectToAction("Edit", "Projects", new { id = item.ProjectID }, "plan"));
        }
        public ActionResult Edit(int id)
        {
            project_plan project_plan = db.project_plan.Single(p => p.PlanID == id);

            ViewBag.ProjectID = new SelectList(db.projects, "ProjectID", "Title", project_plan.ProjectID);
            ViewBag.Project   = db.projects.FirstOrDefault(x => x.ProjectID == project_plan.ProjectID);
            return(View(project_plan));
        }
Beispiel #4
0
        public ActionResult DeleteConfirmed(int id)
        {
            project_plan project_plan = db.project_plan.Single(p => p.PlanID == id);

            db.project_plan.DeleteObject(project_plan);
            db.SaveChanges();
            return(RedirectToAction("Edit", "Projects", new { id = project_plan.ProjectID }, "plan"));
        }
 public ActionResult Edit(project_plan project_plan)
 {
     if (ModelState.IsValid)
     {
         db.project_plan.Attach(project_plan);
         db.ObjectStateManager.ChangeObjectState(project_plan, EntityState.Modified);
         db.SaveChanges();
         return(RedirectToAction("Edit", "Projects", new { id = project_plan.ProjectID }, "plan"));
     }
     ViewBag.ProjectID = new SelectList(db.projects, "ProjectID", "Title", project_plan.ProjectID);
     ViewBag.Project   = db.projects.FirstOrDefault(x => x.ProjectID == project_plan.ProjectID);
     return(View(project_plan));
 }
        //
        // GET: /Admin/Plans/Delete/5

        public ActionResult Delete(int id)
        {
            project_plan project_plan = db.project_plan.Single(p => p.PlanID == id);
            var          project      = db.projects.FirstOrDefault(x => x.ProjectID == project_plan.ProjectID && x.UserID == CurrentUser.UserID);

            if (project == null)
            {
                return(RedirectToAction("Index", "Home"));
            }

            db.project_plan.DeleteObject(project_plan);
            db.SaveChanges();
            return(RedirectToAction("Edit", "Projects", new { id = project_plan.ProjectID }, "plan"));
        }
Beispiel #7
0
        public ActionResult Create(project_plan project_plan)
        {
            if (ModelState.IsValid)
            {
                if (db.project_plan.Any(x => x.ProjectID == project_plan.ProjectID))
                {
                    int order = db.project_plan.Where(x => x.ProjectID == project_plan.ProjectID).Max(x => x.Order);
                    order = order + 1;
                    project_plan.Order = order;
                }
                else
                {
                    project_plan.Order = 20;
                }
                db.project_plan.AddObject(project_plan);
                db.SaveChanges();
                return(RedirectToAction("Edit", "Projects", new { id = project_plan.ProjectID }, "plan"));
            }

            ViewBag.ProjectID = new SelectList(db.projects, "ProjectID", "Title", project_plan.ProjectID);
            ViewBag.Project   = db.projects.FirstOrDefault(x => x.ProjectID == project_plan.ProjectID);
            return(View(project_plan));
        }