コード例 #1
0
        public ActionResult EditProjectManager([Bind(Include = "PmId, Projects, SelectedUser, Id, Name")] AdminProjectViewModel model)
        {
            var           prjId  = model.Projects.Id;
            var           pm     = model.Projects.PmId;
            ProjectHelper helper = new ProjectHelper();

            helper.AddPmToProject(model.SelectedUser, prjId);
            return(RedirectToAction("Index", "Projects"));
        }
コード例 #2
0
        //GET: Assign Project Manager
        public ActionResult AssignPM(int Id)
        {
            AdminProjectViewModel vm     = new AdminProjectViewModel();
            UserRolesHelper       helper = new UserRolesHelper();
            var pms = helper.UsersInRole("ProjectManager");

            vm.PMUsers = new SelectList(pms, "Id", "FirstName");
            vm.Project = db.Projects.Find(Id);

            return(View(vm));
        }
コード例 #3
0
        public ActionResult AssignPM(AdminProjectViewModel adminVm)
        {
            if (ModelState.IsValid)
            {
                var prj = db.Projects.Find(adminVm.project.Id);
                prj.PMID = adminVm.SelectedUser;

                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(adminVm.project.Id));
        }
コード例 #4
0
        public ActionResult EditProjectManager(int id)
        {
            AdminProjectViewModel adminProject = new AdminProjectViewModel();
            var            prj      = db.Projects.Find(id);
            UserRoleHelper helper   = new UserRoleHelper();
            var            selected = helper.UsersInRole("ProjectManager").ToList();

            adminProject.Projects       = new Project();
            adminProject.ProjectManager = new SelectList(selected, "Id", "FullName", selected);
            adminProject.Projects.Id    = prj.Id;
            adminProject.Name           = prj.Name;

            return(View(adminProject));
        }
コード例 #5
0
        public ActionResult AssignPM(AdminProjectViewModel adminVm)
        {
            if (ModelState.IsValid)
            {
                ProjectsHelper helper = new ProjectsHelper();
                var            prj    = db.Projects.Find(adminVm.Project.Id);
                prj.PMID = adminVm.SelectedUser;

                helper.AddUserToProject(prj.PMID, prj.Id);

                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            // return View(adminVm.Project.Id);
            return(View(adminVm));
        }
コード例 #6
0
        public ActionResult EditProjectUser([Bind(Include = "Id, Name, User, Projects, SelectedUsers, TempUrl")] AdminProjectViewModel model)
        {
            var           prjId  = model.Projects.Id;
            ProjectHelper helper = new ProjectHelper();

            foreach (var userRemove in db.Users.Select(u => u.FullName).ToList())
            {
                helper.RemoveUserToProject(userRemove, prjId);
            }
            foreach (var userAdd in model.SelectedUsers)
            {
                helper.AddUserToProject(userAdd, prjId);
            }
            //return Redirect(Request.UrlReferrer.ToString());
            //return RedirectToRoute(model.TempUrl);
            return(RedirectToAction("Index", "Projects"));
        }
コード例 #7
0
        public ActionResult EditProjectUser(int id, string initialUrl)
        {
            ViewBag.SaveUrl = initialUrl;
            var prj = db.Projects.Find(id);
            AdminProjectViewModel adminProject = new AdminProjectViewModel();
            ProjectHelper         helper       = new ProjectHelper();
            UserRoleHelper        roleHelper   = new UserRoleHelper();
            var selected = roleHelper.UsersInRole("Developer").ToList();

            //var selected = db.Users.ToList();
            adminProject.Projects    = new Project();
            adminProject.User        = new MultiSelectList(selected, "Id", "FullName", selected);
            adminProject.Projects.Id = prj.Id;
            adminProject.Name        = prj.Name;

            return(View(adminProject));
        }
コード例 #8
0
        //Func Desc: Used to return a project from its id.
        //    Input: Int representing id of project to locate.
        //   Output: An instance of the project that has the specified id, or null
        public object GetProject(int?project_id)  //Should this be nullable? ***
        {
            //Input checks
            if (project_id == null)
            {
                return(null);
            }
            if (project_id < 0)
            {
                return(null);
            }

            using (var context = new MainDBEntities())
            {
                ApplicationSpecificMapper mapper = new ApplicationSpecificMapper();

                if (this.GetType() == typeof(AdminAccess))
                {
                    //Map located project to project view model
                    AdminProjectViewModel vm_project = (AdminProjectViewModel)mapper.Map(context.Projects.Find(project_id), typeof(AdminProjectViewModel));

                    //Return project with given id or null
                    return(vm_project);
                }
                else if (this.GetType() == typeof(AmbassadorAccess))
                {
                    //Map located project to project view model
                    AmbassProjectViewModel vm_project = (AmbassProjectViewModel)mapper.Map(context.Projects.Find(project_id), typeof(AmbassProjectViewModel));

                    //Make sure project isn't archived
                    if (vm_project.IsArchived == true)
                    {
                        return(null);
                    }

                    //Return project with given id or null
                    return(vm_project);
                }
                else if (this.GetType() == typeof(ContributorAccess))
                {
                    //Map located project to project view model
                    ContributorProjectViewModel vm_project = (ContributorProjectViewModel)mapper.Map(context.Projects.Find(project_id), typeof(ContributorProjectViewModel));

                    //Make sure project isn't archived
                    if (vm_project.IsArchived == true)
                    {
                        return(null);
                    }

                    //Return project with given id or null
                    return(vm_project);
                }
                else if (this.GetType() == typeof(DefaultAccess))
                {
                    //Map located project to project view model
                    ProjectViewModel vm_project = (ProjectViewModel)mapper.Map(context.Projects.Find(project_id), typeof(ProjectViewModel));

                    //Make sure project isn't archived
                    if (vm_project.IsArchived == true)
                    {
                        return(null);
                    }

                    //Return project with given id or null
                    return(vm_project);
                }
                else
                {
                    //Invalid access object
                    Debug.WriteLine("\n\n***** " +
                                    "Access object type wasn't recognized during GetProject(). " +
                                    "ERROR IN: CommerceIdeaBank.DatabaseInterface.BusinessLogic.ContributorAccess GetProject()" +
                                    "*****\n\n");

                    return(null);
                }
            }
        }
コード例 #9
0
        //Func Desc: Used to submit project idea
        //    Input: A ProjectView instance
        //   Output: Bool indicating submission status. T = successful submission, F = failure to submit.
        public bool SubmitProject(object new_project)
        {
            //Input checks
            if (new_project == null)
            {
                return(false);
            }

            using (var context = new MainDBEntities())
            {
                //Determine response based on access privilages
                if (this.GetType() == typeof(AdminAccess)) // IF ADMINISTRATOR
                {
                    try
                    {
                        //Cast object to admin project view model type
                        AdminProjectViewModel admin_project =
                            (AdminProjectViewModel)new_project;

                        //Create new project instance
                        Project proj = new Project();

                        //Transfer necessary values
                        proj.ProjectName           = admin_project.ProjectName;
                        proj.ProjectDesc           = admin_project.ProjectDesc;
                        proj.BusinessJustification = admin_project.BusinessJustification;
                        proj.Username   = admin_project.Username;
                        proj.Status     = IdeaStatus.SUBMITTED;
                        proj.IsArchived = false; //Not yet archived
                        proj.PostDate   = DateTime.Now;
                        proj.AssignDate = null;
                        proj.FinishDate = null;

                        //Submit the project to the db
                        context.Projects.Add(proj);

                        //Save changes
                        context.SaveChanges();

                        //Indicate successful submission
                        return(true);
                    }
                    catch
                    {
                        //Return false indicating failure to submit project
                        return(false);
                    }
                }
                else if (this.GetType() == typeof(AmbassadorAccess))
                {
                    try
                    {
                        //Cast object to contributor project view model type
                        AmbassProjectViewModel contributor_project =
                            (AmbassProjectViewModel)new_project;

                        //Create new project instance
                        Project proj = new Project();

                        //Transfer necessary values
                        proj.ProjectName           = contributor_project.ProjectName;
                        proj.ProjectDesc           = contributor_project.ProjectDesc;
                        proj.BusinessJustification = contributor_project.BusinessJustification;
                        proj.Username   = contributor_project.Username;
                        proj.Status     = IdeaStatus.SUBMITTED;
                        proj.IsArchived = false; //Not yet archived
                        proj.PostDate   = DateTime.Now;
                        proj.AssignDate = null;
                        proj.FinishDate = null;

                        //Submit the project to the db
                        context.Projects.Add(proj);

                        //Save changes
                        context.SaveChanges();

                        //Indicate successful submission
                        return(true);
                    }
                    catch
                    {
                        //Return false indicating failure to submit project
                        return(false);
                    }
                }
                else if (this.GetType() == typeof(ContributorAccess))
                {
                    try
                    {
                        //
                        ContributorProjectViewModel contributor_project = (ContributorProjectViewModel)new_project;

                        //Create new project instance
                        Project proj = new Project();

                        //Transfer necessary values
                        proj.ProjectName           = contributor_project.ProjectName;
                        proj.ProjectDesc           = contributor_project.ProjectDesc;
                        proj.BusinessJustification = contributor_project.BusinessJustification;
                        proj.Username   = contributor_project.Username;
                        proj.Status     = IdeaStatus.SUBMITTED;
                        proj.IsArchived = false; //Not yet archived
                        proj.PostDate   = DateTime.Now;
                        proj.AssignDate = null;
                        proj.FinishDate = null;

                        //Submit the project to the db
                        context.Projects.Add(proj);

                        //Save changes
                        context.SaveChanges();

                        //Indicate successful submission
                        return(true);
                    }
                    catch
                    {
                        //Return false indicating failure to submit project
                        return(false);
                    }
                }
                else
                {
                    //Access object not recognized
                    Debug.WriteLine("\n\n***** " +
                                    "Access object type wasn't recognized during SubmitProject(). " +
                                    "ERROR IN: CommerceIdeaBank.DatabaseInterface.BusinessLogic.ContributorAccess SubmitProject()" +
                                    "*****\n\n");

                    //Indicate error
                    return(false);
                }
            }
        }