Example #1
0
        public ActionResult Edit(ProjectViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                var project = db.Projects.Single(x => x.Id == viewModel.Id);

                if (!EntityAuthorization.ProjectEditDelete(project))
                {
                    return(HttpNotFound());
                }

                project.InitFromViewModel(viewModel);
                project.ModifiedUserId   = Viola.Models.User.GetCurrentUserId();
                project.ModifiedDatetime = DateTime.Now.ToUniversalTime();

                db.Entry(project).State = EntityState.Modified;
                db.SaveChanges();
                ProjectTeam.Create(project.Id, Request.Form.GetValues("UserIdMulti"));
                ProjectTeam.AddProjectManagerToTeam(project);

                return(RedirectToAction("Details", "Projects", new { id = project.Id }));
            }
            ViewBag.ManagerUserId = new SelectList(Viola.Models.User.GetUsers(), "Id", "FullName", viewModel.ManagerUserId);
            ViewBag.UserIdMulti   = new MultiSelectList(Viola.Models.User.GetUsers(), "Id", "FullName", ProjectTeam.UserIdSelection(viewModel.Id));
            return(View(viewModel));
        }
Example #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            Project project = db.Projects.Find(id);

            if (!EntityAuthorization.ProjectEditDelete(project))
            {
                return(HttpNotFound());
            }

            db.Projects.Remove(project);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #3
0
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            Project project = db.Projects.Find(id);

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

            if (!EntityAuthorization.ProjectEditDelete(project))
            {
                return(HttpNotFound());
            }

            return(View(project));
        }
Example #4
0
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            Project project = db.Projects.Find(id);

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

            if (!EntityAuthorization.ProjectEditDelete(project))
            {
                return(HttpNotFound());
            }

            ViewBag.ManagerUserId = new SelectList(Viola.Models.User.GetUsers(), "Id", "FullName", project.ManagerUserId);
            ViewBag.UserIdMulti   = new MultiSelectList(Viola.Models.User.GetUsers(), "Id", "FullName", ProjectTeam.UserIdSelection(project.Id));
            return(View(Mapper.Map <Project, ProjectViewModel>(project)));
        }