Exemplo n.º 1
0
        public ActionResult AssignUsers(AssignProjects model, string userId)
        {
            ProjectHelper projectHelp = new ProjectHelper();

            model.user = db.Users.Where(u => u.Id == userId).FirstOrDefault();

            foreach (var project in projectHelp.ListUserProjects(userId))
            {
                Projects projectDel = db.projects.Find(project.Id);
                projectDel.projectUsers.Remove(model.user);
                db.Entry(projectDel).State = EntityState.Modified;
                db.SaveChanges();
            }

            if (model.selectedProjects == null)
            {
                return(RedirectToAction("ManageUsers"));
            }

            for (int index = 0; index < model.selectedProjects.Length; index++)
            {
                var projId = model.selectedProjects[index];
                model.user.Projects.Add(db.projects.Find(projId));
            }

            db.SaveChanges();
            return(RedirectToAction("ManageUsers"));
        }
Exemplo n.º 2
0
        public void assignProject()
        {
            using (var context = new CompanyDbContext())
            {
                Console.WriteLine("Assign Projects:");
                Console.Write("Enter Employee_Name:");
                string name = Console.ReadLine();
                var    b    = context.Employees.Single(t => t.EmployeeName == name);

                int count = context.EmployeeLeave.Count(t => t.EmployeeId == b.EmployeeId);
                if (count == 0)
                {
                    assign.EmployeeId = b.EmployeeId;
                    Console.Write("Enter ProjectName:");
                    string pname = Console.ReadLine();
                    var    p     = context.Projects.Single(t => t.ProjectName == pname);
                    assign.ProjectId = p.ProjectId;
                    AssignProjects.Add(assign);
                    SaveChanges();
                }
                else
                {
                    Console.Write("Employee is on leave");
                }
            }
        }
Exemplo n.º 3
0
        public JsonResult UpdateProjectTeam(AssignProjects projectTeam)
        {
            AssignProjectManager projectTeamManager = new AssignProjectManager();
            var result = projectTeamManager.Update(projectTeam);

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 4
0
        public void Delete(int Id)
        {
            AssignProjects pro = dSRContext.assignProjects.Where(o => o.Id == Id).First();

            dSRContext.assignProjects.Remove(pro);
            dSRContext.SaveChanges();
        }
Exemplo n.º 5
0
        public AssignProjects Update(AssignProjects projectTeam)
        {
            AssignProjects pro = dSRContext.assignProjects.Where(o => o.Id == projectTeam.Id).First();

            pro.UserId      = projectTeam.UserId;
            pro.ProjectId   = projectTeam.ProjectId;
            pro.Description = projectTeam.Description;
            pro.IsActive    = projectTeam.IsActive;
            dSRContext.SaveChanges();
            return(projectTeam);
        }
Exemplo n.º 6
0
        public ActionResult AssignUsers(string userId)
        {
            var userIn     = db.Users.Where(u => u.Id == userId).FirstOrDefault();
            var projectsId = new List <int>();

            var model = new AssignProjects
            {
                user     = userIn,
                projects = new MultiSelectList(db.projects, "Id", "name", projectsId)
            };

            return(View(model));
        }
Exemplo n.º 7
0
        public bool SaveAssignedProjects(AssignProjects assignProjectsModel)
        {
            bool result = false;

            using (var _context = new DatabaseContext())
            {
                try
                {
                    if (assignProjectsModel.Projects != null)
                    {
                        for (int i = 0; i < assignProjectsModel.Projects.Count(); i++)
                        {
                            var AssignedProjects = new AssignedProjects
                            {
                                ManagerId = assignProjectsModel.ManagerId,
                                Status    = "A",
                                ProjectId = assignProjectsModel.Projects[i].ProjectID
                            };
                            _context.AssignedProjects.Add(AssignedProjects);
                            _context.SaveChanges();
                        }
                    }
                    else if (assignProjectsModel.Users != null)
                    {
                        for (int i = 0; i < assignProjectsModel.Users.Count(); i++)
                        {
                            var AssignedProjects = new AssignedProjects
                            {
                                ManagerId = assignProjectsModel.Users[i].RegistrationID,
                                Status    = "A",
                                ProjectId = assignProjectsModel.ProjectId
                            };
                            _context.AssignedProjects.Add(AssignedProjects);
                            _context.SaveChanges();
                        }
                    }

                    result = true;
                }
                catch (Exception)
                {
                    throw;
                }
                return(result);
            }
        }
Exemplo n.º 8
0
 public void LoadProjects(AssignProjects callback) {
     callback(base.LoadProjects());
 }
Exemplo n.º 9
0
 void LoadProjectsAsync_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) {
     AssignProjects callback = (AssignProjects)((object[])e.Result)[1];
     IEnumerable<Project> results = (IEnumerable<Project>)((object[])e.Result)[0];
     callback(results);
 }
Exemplo n.º 10
0
 public void LoadProjects(AssignProjects callback) {
     BackgroundWorker loadProjectsAsync = new BackgroundWorker();
     loadProjectsAsync.DoWork += new DoWorkEventHandler(LoadProjectsAsync_DoWork);
     loadProjectsAsync.RunWorkerCompleted += new RunWorkerCompletedEventHandler(LoadProjectsAsync_RunWorkerCompleted);
     loadProjectsAsync.RunWorkerAsync(callback);
 }
Exemplo n.º 11
0
 public AssignProjects Add(AssignProjects projectTeam)
 {
     dSRContext.assignProjects.Add(projectTeam);
     dSRContext.SaveChanges();
     return(projectTeam);
 }
Exemplo n.º 12
0
        public IHttpActionResult SaveAssignedProjects(AssignProjects assignProjectsModel)
        {
            var result = _IProjectRepository.SaveAssignedProjects(assignProjectsModel);

            return(Ok(result));
        }