public ActionResult AssignTicket(int id, int pId)
        {
            //List<ProjectManagerViewModel> ListPMModel = new List<ProjectManagerViewModel>();
            var PModel  = new ProjectManagerViewModel();
            var project = new Projects();
            var uList   = new List <ApplicationUser>();

            if (id != null)
            {
                var currTic     = db.Tickets.Find(id);
                var currproject = db.Projects.Find(pId);
                PModel.Tid = id;
                PModel.Pid = pId;
                project.Id = pId;
                var Devs = db.Roles.FirstOrDefault(r => r.Name == "Developer");
                uList             = db.Users.Where(u => u.Roles.Any(r => r.RoleId == Devs.Id)).ToList();
                PModel.Developers = new MultiSelectList(uList, "id", "FirstName", PModel.SelectedDevelopers);
                return(View(PModel));
            }
            var Devss = db.Roles.FirstOrDefault(r => r.Name == "Developer");

            ViewBag.Developer     = new SelectList(Devss.Id, "Id", "Name");
            ViewData["Developer"] = new SelectList(Devss.Id, "Id", "Name");
            return(RedirectToAction("Index"));
        }
예제 #2
0
        public ActionResult AssignProject(ProjectManagerViewModel model, int projectId)
        {
            //var FindUserToPost = db.Users.Find(model.Id);
            //var projectID = db.Projects.Find(projectId);
            ProjectHelper projectHelp = new ProjectHelper(db);
            //foreach (var RemoveProject in db.Projects.Select(r => r.Name).ToList())
            //{
            //    projectHelp.RemoveUserToProject(model.Id, projectId);
            //}
            //var ListPModel = new List<ApplicationUser>();
            //var PManagers = db.Roles.All(r => r.Name == "ProjectManager");
            var project = new Projects();



            foreach (var PMid in model.SelectedProjectManager)
            {
                project.PManagerID = PMid;

                projectHelp.AddUserToProject(PMid, projectId);
                //db.Projects.Add(project);
                //db.SaveChanges();
            }


            return(RedirectToAction("Index", "Projects"));
        }
        public async Task <ActionResult> AssignTicket(ProjectManagerViewModel model, int tId, int pId)
        {
            ApplicationDbContext db   = new ApplicationDbContext();
            var           PModel      = new ProjectManagerViewModel();
            ProjectHelper projectHelp = new ProjectHelper(db);

            model.Pid = pId;
            var currDev = db.Users.Find(model.Id);
            var T       = db.Tickets.Find(tId);

            if (ModelState.IsValid)
            {
                foreach (var DevId in model.SelectedDevelopers)
                {
                    projectHelp.AddDevToTicket(DevId, tId);
                }
            }


            var svc = new EmailService();
            var msg = new IdentityMessage();

            msg.Subject = "New Ticket Assignment";
            msg.Body    = "\r\n You have recieved a new ticket assign titled," + T.Title + "with the following description:" + T.Description + "\r\n";

            msg.Destination = T.AssignedTo.Email;

            await svc.SendAsync(msg);

            var Devs = db.Roles.FirstOrDefault(r => r.Name == "Developer");

            ViewBag.Developer = new SelectList(Devs.Id, "Id", "Name");
            //ViewBag.AssignedToId = new SelectList(db.Users, "Id", "FirstName", tickets.AssignedToId);
            return(RedirectToAction("Details", "Projects", new { id = pId }));
        }
예제 #4
0
        public ActionResult Create(ProjectManagerViewModel model)
        {
            try
            {
                // TODO: Add insert logic here
                if (!ModelState.IsValid)
                {
                    return(View(model));
                }
                var ProjectManager = _mapper.Map <ProjectManager>(model);
                var isSuccess      = _repo.Create(ProjectManager);
                if (!isSuccess)
                {
                    ModelState.AddModelError("", "Something Went Wrong!");
                    return(View(model));
                }

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                ModelState.AddModelError("", "Something Went Wrong!");
                return(View(model));
            }
        }
예제 #5
0
        public ActionResult Delete(int id, ProjectManagerViewModel model)
        {
            try
            {
                // TODO: Add delete logic here
                var ProjectManager = _repo.FindById(id);
                if (ProjectManager == null)
                {
                    return(NotFound());
                }

                var isSuccess = _repo.Delete(ProjectManager);
                if (!isSuccess)
                {
                    return(View(model));
                }


                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View(model));
            }
        }
예제 #6
0
        public ActionResult UnassignProject(int id)
        {
            if (id != null)
            {
                var ListPModel = new List <ApplicationUser>();
                //var FindUser = db.Users.Find(id);
                var             PModel   = new ProjectManagerViewModel();
                UserRolesHelper userRole = new UserRolesHelper(db);
                PModel.Pid = id;
                var PManagers = db.Roles.FirstOrDefault(r => r.Name == "ProjectManager");
                ListPModel            = db.Users.Where(u => u.Roles.Any(r => r.RoleId == PManagers.Id)).ToList();
                PModel.ProjectManager = new MultiSelectList(ListPModel, "id", "FirstName", PModel.SelectedProjectManager);
                return(View(PModel));
            }

            return(RedirectToAction("Index"));
        }
예제 #7
0
        public ActionResult Index()
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(RedirectToAction("Login", "Account"));
            }

            List <ProjectManagerViewModel> projectList = new List <ProjectManagerViewModel>();

            foreach (var project in db.Projects.OrderBy(p => p.Name).ToList())
            {
                ProjectManagerViewModel projectvm = new ProjectManagerViewModel();
                projectvm.Project = project;
                projectvm.User    = db.Users.Find(project.ProjectManagerUserId);
                projectList.Add(projectvm);
            }

            return(View(projectList));
        }
예제 #8
0
        public ActionResult Index(int?page, int?pageSize)
        {
            var authorizedIds = m_dbAdapter.Authority.GetAuthorizedProjectIds();
            var projects      = m_dbAdapter.Project.GetProjects(page ?? 1, pageSize ?? 10, true, authorizedIds);

            var viewModel = new ProjectManagerViewModel();

            viewModel.PageInfo = Toolkit.ConvertPageInfo(projects);

            var filterDate = DateTime.Now.AddYears(10);//截止时间设定为未来十年内,仅为触发日期筛选

            foreach (var project in projects.Items)
            {
                var projectView = Toolkit.ConvertProject(project);
                if (projectView != null)
                {
                    var tasks = m_dbAdapter.Task.GetTasks(1, 1, filterDate, project.ProjectId,
                                                          new List <TaskStatus>()
                    {
                        TaskStatus.Waitting, TaskStatus.Running, TaskStatus.Finished,
                        TaskStatus.Skipped, TaskStatus.Overdue, TaskStatus.Error
                    },
                                                          new List <int> {
                        project.ProjectId
                    });
                    if (tasks.Items != null && tasks.Items.Count > 0)
                    {
                        projectView.CurrentTask = Toolkit.ConvertTask(tasks.Items.First());
                    }

                    projectView.Message = m_dbAdapter.News.CountNewsByProjectAndStatus(projectView.Id, NewsConsts.NewsStatusAll)
                                          - m_dbAdapter.News.CountNewsByProjectAndStatus(projectView.Id, NewsConsts.NewsStatusRead);
                    viewModel.Projects.Add(projectView);
                }
            }

            viewModel.HasCreateProjectAuthority = m_dbAdapter.Authority.IsAuthorized(AuthorityType.CreateProject);
            viewModel.HasEditModelAuthority     = m_dbAdapter.Authority.IsAuthorized(AuthorityType.ModifyModel);
            viewModel.HasEditProjectAuthority   = m_dbAdapter.Authority.IsAuthorized(AuthorityType.ModifyTask);
            viewModel.IsSuperUser = m_dbAdapter.SuperUser.IsSuperUser();
            return(View(viewModel));
        }
예제 #9
0
        public string AddUpdateProjectManager(ProjectManagerViewModel model)
        {
            db = new SR_Log_DatabaseSQLEntities();
            string UserId = "";

            using (var context = new SR_Log_DatabaseSQLEntities())
            {
                tblGroupUser user = new tblGroupUser();
                user.Userid     = model.Userid;
                user.UserName   = model.UserName;
                user.Group_Name = "TimesheetProjectMgr";
                context.tblGroupUsers.Add(user);
                context.SaveChanges();
                UserId = user.Userid;
            }



            return(UserId);
        }
        public ActionResult AssignTicket(ProjectManagerViewModel model, int tId, int pId)
        {
            ApplicationDbContext db   = new ApplicationDbContext();
            var           PModel      = new ProjectManagerViewModel();
            ProjectHelper projectHelp = new ProjectHelper(db);

            model.Pid = pId;
            var currDev = db.Users.Find(model.Id);

            if (ModelState.IsValid)
            {
                foreach (var DevId in model.SelectedDevelopers)
                {
                    projectHelp.AddDevToTicket(DevId, tId);

                    projectHelp.RemoveT(tId, DevId);
                }
            }
            var Devs = db.Roles.FirstOrDefault(r => r.Name == "Developer");

            ViewBag.Developer = new SelectList(Devs.Id, "Id", "Name");
            //ViewBag.AssignedToId = new SelectList(db.Users, "Id", "FirstName", tickets.AssignedToId);
            return(RedirectToAction("Details", "Projects", new { id = pId }));
        }
        public ActionResult ViewProjects()
        {
            List <Project> projects = ProjectManagerViewModel.GetAllProjectsAsync().Result;

            return(View(projects));
        }
예제 #12
0
 public ProjectManager()
 {
     InitializeComponent();
     _viewModel   = (ProjectManagerViewModel)this.DataContext;
     this.Loaded += ProjectManager_Loaded;
 }