public ActionResult Delete(Project project)
 {
     using (ProjectRiderDbContext db = new ProjectRiderDbContext())
     {
         db.Projects.Attach(project);
         db.Entry(project).State = EntityState.Deleted;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
 }
        public ActionResult EditConfirm(
            [Bind(Include = "Id,Title,Description,Budget")] Project project)
        {
            if (ModelState.IsValid)
            {
                db.Entry(project).State = EntityState.Modified;
                db.SaveChanges();
            }

            return(Redirect("/"));
        }
 public ActionResult Create(Project project)
 {
     if (!ModelState.IsValid)
     {
         return(View(project));
     }
     using (ProjectRiderDbContext db = new ProjectRiderDbContext())
     {
         db.Entry(project).State = EntityState.Added;
         db.SaveChanges();
     }
     return(RedirectToAction("Index"));
 }
 public ActionResult Edit(Project project)
 {
     if (!ModelState.IsValid)
     {
         return(View(project));
     }
     using (ProjectRiderDbContext db = new ProjectRiderDbContext())
     {
         db.Projects.Attach(project);
         db.Entry(project).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
 }
        public ActionResult EditConfirm(int id, Project project)
        {
            if (ModelState.IsValid)
            {
                using (var database = new ProjectRiderDbContext())
                {
                    var task = database.Projects.FirstOrDefault(t => t.Id == project.Id);

                    task.Budget      = project.Budget;
                    task.Title       = project.Title;
                    task.Description = project.Description;

                    database.Entry(task).State = System.Data.Entity.EntityState.Modified;
                    database.SaveChanges();

                    return(RedirectToAction("Index"));
                }
            }
            return(View());
        }
        public ActionResult EditConfirm(int id, Project project)
        {
            using (var db = new ProjectRiderDbContext())
            {
                var projectEntity = db.Projects
                                    .Where(p => p.Id == id)
                                    .First();

                if (projectEntity == null)
                {
                    return(HttpNotFound());
                }

                projectEntity.Title       = project.Title;
                projectEntity.Description = project.Description;
                projectEntity.Budget      = project.Budget;

                db.Entry(projectEntity).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }
        }