public ActionResult Create(Project project)
 {
     if (this.ModelState.IsValid)
     {
         db.Projects.Add(project);
         db.SaveChanges();
         return(Redirect("/"));
     }
     return(View(project));
 }
 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"));
     }
 }
Example #3
0
        public ActionResult Create(Project project)
        {
            using (var context = new ProjectRiderDbContext())
            {
                context.Projects.Add(project);
                context.SaveChanges();

                return(this.Redirect("/"));
            }
        }
Example #4
0
        public ActionResult Create(Project project)
        {
            if (!ModelState.IsValid)
            {
                return(RedirectToAction("Index"));
            }

            context.Projects.Add(project);
            context.SaveChanges();

            return(RedirectToAction("Index"));;
        }
Example #5
0
        public ActionResult DeleteConfirm(int id, Project reportModel)
        {
            using (var context = new ProjectRiderDbContext())
            {
                Project projectFromDB = context.Projects.Find(id);

                context.Projects.Remove(projectFromDB);
                context.SaveChanges();

                return(Redirect("/"));
            }
        }
Example #6
0
        public ActionResult DeleteConfirm(int id, Project reportModel)
        {
            using (var db = new ProjectRiderDbContext())
            {
                var projectFromDb = db.Projects.Find(id);

                db.Projects.Remove(projectFromDb);
                db.SaveChanges();

                return(Redirect("/"));
            }
        }
Example #7
0
 public ActionResult Create(Project project)
 {
     if (ModelState.IsValid)
     {
         using (var db = new ProjectRiderDbContext())
         {
             db.Projects.Add(project);
             db.SaveChanges();
             return(Redirect("/"));
         }
     }
     return(View());
 }
 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"));
 }
Example #9
0
 public ActionResult Create(Project project)
 {
     if (ModelState.IsValid)
     {
         using (var database = new ProjectRiderDbContext())
         {
             database.Projects.Add(project);
             database.SaveChanges();
             return(RedirectToAction("Index"));
         }
     }
     return(View());
 }
Example #10
0
        public ActionResult Create(Project project)
        {
            using (var context = new ProjectRiderDbContext())
            {
                if (this.ModelState.IsValid)
                {
                    context.Projects.Add(project);
                    context.SaveChanges();
                    return(Redirect("/"));
                }

                return(View(project));
            }
        }
 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"));
     }
 }
Example #12
0
        public ActionResult EditConfirm(int id, Project project)
        {
            using (var db = new ProjectRiderDbContext())
            {
                Project currentProject = db.Projects.Find(id);

                currentProject.Title       = project.Title;
                currentProject.Description = project.Description;
                currentProject.Budget      = project.Budget;

                db.SaveChanges();

                return(Redirect("/"));
            }
        }
Example #13
0
        public ActionResult EditConfirm(int id, Project project)
        {
            using (var context = new ProjectRiderDbContext())
            {
                Project taskFromDb = context.Projects.Find(id);

                taskFromDb.Title       = project.Title;
                taskFromDb.Description = project.Description;
                taskFromDb.Budget      = project.Budget;

                context.SaveChanges();

                return(Redirect("/"));
            }
        }
        public ActionResult Create(Project project)
        {
            //if (!ModelState.IsValid)
            //{
            //    return RedirectToAction("Index");
            //}

            using (var db = new ProjectRiderDbContext())
            {
                db.Projects.Add(project);
                db.SaveChanges();
            }

            return(RedirectToAction("Index"));
        }
Example #15
0
        public ActionResult DeleteConfirm(int id, Project reportModel)
        {
            using (var context = new ProjectRiderDbContext())
            {
                var projectFromDb = context.Projects.Find(id);
                if (projectFromDb == null)
                {
                    return(HttpNotFound());
                }

                context.Projects.Remove(projectFromDb);
                context.SaveChanges();

                return(Redirect("/"));
            }
        }
Example #16
0
        public ActionResult DeleteConfirm(int id, Project reportModel)
        {
            using (var database = new ProjectRiderDbContext())
            {
                var project = database.Projects.Where(f => f.Id == id).First();

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

                database.Projects.Remove(project);
                database.SaveChanges();
                return(RedirectToAction("Index"));
            }
        }
        public ActionResult DeleteConfirm(int id, Project projectModel)
        {
            //if (!ModelState.IsValid)
            //{
            //    return RedirectToAction("Index");
            //}

            using (var db = new ProjectRiderDbContext())
            {
                var projectToDelete = db.Projects.FirstOrDefault(x => x.Id == id);

                db.Projects.Remove(projectToDelete);
                db.SaveChanges();
            }

            return(RedirectToAction("Index"));
        }
        public ActionResult EditConfirm(int id, Project projectModel)
        {
            //if (!ModelState.IsValid)
            //{
            //    return RedirectToAction("Index");
            //}

            using (var db = new ProjectRiderDbContext())
            {
                var projectToEdit = db.Projects.FirstOrDefault(x => x.Id == id);

                projectToEdit.Title       = projectModel.Title;
                projectToEdit.Description = projectModel.Description;
                projectToEdit.Budget      = projectModel.Budget;

                db.SaveChanges();
            }

            return(RedirectToAction("Index"));
        }
Example #19
0
        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());
        }
Example #20
0
        public ActionResult EditConfirm(int id, Project project)
        {
            if (ModelState.IsValid)
            {
                using (var db = new ProjectRiderDbContext())
                {
                    var projectFromDb = db.Projects.Find(project.Id);
                    if (projectFromDb != null)
                    {
                        projectFromDb.Title       = project.Title;
                        projectFromDb.Description = project.Description;
                        projectFromDb.Budget      = project.Budget;
                        db.SaveChanges();
                    }
                }

                return(Redirect("/"));
            }

            return(View(project));
        }
        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"));
            }
        }