public int Save(ProjectRole ProjectRole)
        {
            ProjectRole _role = _context.ProjectRoles.Where(p => p.ProjectID == ProjectRole.ProjectID).Where(p => p.RoleID == ProjectRole.RoleID).FirstOrDefault();

            if (_role == null)
            {
                _context.ProjectRoles.Add(ProjectRole);
            }
            else
            {
                _role.UserID   = ProjectRole.UserID;
                _role.UserName = ProjectRole.UserName;
            }
            //if (ProjectRole.ProjectRoleID == 0)
            //{

            //}
            //else
            //{
            //    ProjectRole _dbEntry = _context.ProjectRoles.Find(ProjectRole.ProjectRoleID);
            //    if (_dbEntry!=null)
            //    {
            //        _dbEntry.ProjectID = ProjectRole.ProjectID;
            //        _dbEntry.RoleID = ProjectRole.RoleID;
            //        _dbEntry.UserID = ProjectRole.UserID;
            //        _dbEntry.UserName = ProjectRole.UserName;
            //    }
            //}
            _context.SaveChanges();
            return(ProjectRole.ProjectRoleID);
        }
예제 #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            ProjectRole projectRole = _projectRoleService.GetById((int)id);

            _projectRoleService.Delete(projectRole.ID);
            return(RedirectToAction("Index"));
        }
예제 #3
0
        public async Task Will_only_run_tests_with_matching_role_if_specified(ProjectRole type)
        {
            _configServiceMock.Setup(m => m.GetConfigurationAsync(It.IsAny <CommandOptions>()))
            .ReturnsAsync(SampleProjects.ConfigurationDefault)
            .Verifiable();
            _runnerServiceMock.Setup(m => m.TestAsync(
                                         It.Is <IList <Project> >(projects => projects.All(p => p.Roles.Contains(type))),
                                         It.Is <CommandOptions>(o => o.Roles.Contains(type)),
                                         It.IsAny <CancellationToken>()))
            .Callback((IList <Project> projects, CommandOptions options, CancellationToken token) =>
            {
                foreach (var p in projects)
                {
                    p.Processes.Add(new AppProcess(new Process(), AppTask.Test, AppStatus.Success));
                }
            })
            .Returns((IList <Project> projects, CommandOptions options, CancellationToken token) => Task.FromResult(projects))
            .Verifiable();

            TestCommand command = CreateCommand();

            command.Roles = new ProjectRole[] { type };

            int testProjectCount = await command.OnExecute();

            Assert.Equal(0, testProjectCount);

            _configServiceMock.Verify();
            _runnerServiceMock.Verify();
        }
예제 #4
0
        public bool UserVerification(int?projectId, int?userId, ProjectRole role)
        {
            ProjectRole[] roles;

            switch (role)
            {
            case ProjectRole.Owner:
                roles = new[] { ProjectRole.Owner };
                break;

            case ProjectRole.Admin:
                roles = new[] { ProjectRole.Admin, ProjectRole.Owner };
                break;

            case ProjectRole.Manager:
                roles = new[] { ProjectRole.Manager, ProjectRole.Admin, ProjectRole.Owner };
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(role));
            }

            return(Role.Verify(
                       projectId ?? throw new ArgumentNullException(nameof(projectId)),
                       userId ?? throw new ArgumentNullException(nameof(userId)),
                       roles
                       ));
        }
예제 #5
0
        public ActionResult Edit(ProjectRole model)
        {
            try
            {
                // TODO: Add update logic here
                if (!ModelState.IsValid)
                {
                    return(View(model));
                }
                var ProjectRole = _mapper.Map <ProjectRole>(model);
                var isSuccess   = _repo.Update(ProjectRole);
                if (!isSuccess)
                {
                    ModelState.AddModelError("", "Something Went Wrong!");
                    return(View(model));
                }

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                ModelState.AddModelError("", "Something Went Wrong!");
                return(View(model));
            }
        }
        public void Delete(int id)
        {
            ProjectRole projectrole = _db.ProjectRoles.Find(id);

            _db.ProjectRoles.Remove(projectrole);
            _db.SaveChanges();
        }
예제 #7
0
        public ActionResult Create(ProjectRoleCreateDTO dto)
        {
            string userID = User.Identity.GetUserId();

            if (dto.Role == Role.Owner ||                                                                   // owner role cannot be assigned
                (dto.Role == Role.Manager && !this.db.HasProjectRole(dto.ProjectID, userID, Role.Owner)) || // only the owner of the project can designate a manager
                !this.db.HasProjectRole(dto.ProjectID, userID, Role.Manager)                                // only manager can add workers and clients
                )
            {
                return(new HttpStatusCodeResult(HttpStatusCode.Forbidden));
            }
            if (ModelState.IsValid)
            {
                if (this.db.Projects.Find(dto.ProjectID).Status == ProjectStatus.Completed)
                {
                    return(this.Redirect(String.Format("/Projects/Users/{0}", dto.ProjectID)));
                }
                ProjectRole role = new ProjectRole()
                {
                    ProjectID = dto.ProjectID,
                    Role      = dto.Role,
                    UserID    = dto.UserID
                };
                db.ProjectRoles.Add(role);
                db.SaveChanges();
                return(this.RedirectToAction("Index", "Projects"));
            }
            else
            {
                return(View());
            }
        }
예제 #8
0
        public Task <PartialViewResult> LeftMenu()
        {
            var userName = string.Empty;

            if (HttpContext.User.Identity.IsAuthenticated)
            {
                userName = HttpContext.User.Identity.Name;
            } //if
            return
                (Task.Factory.StartNew(() =>
            {
                ProjectRole role = null;
                var token = GetToken(userName);
                if (token != null)
                {
                    role = ProjectRoleSet.GetKindByID(token.User.ProjectRoleID);
                }
                return role;
            }).ContinueWith(
                     t =>
            {
                return PartialView("LeftMenu", t.Result);
            }
                     ));
        }
        public async Task <UserManagerResponse> CreateRoleAsync(ProjectRole model)
        {
            var roleExist = await this._roleManager.RoleExistsAsync(model.Name);

            if (!roleExist)
            {
                var result = await this._roleManager.CreateAsync(new IdentityRole { Name = model.Name });

                if (result.Succeeded)
                {
                    return new UserManagerResponse
                           {
                               Message   = "Role is created successfullly.",
                               IsSuccess = true,
                           }
                }
                ;

                return(new UserManagerResponse
                {
                    Message = "something went wrong.",
                    IsSuccess = false,
                    Errors = result.Errors.Select(e => e.Description)
                });
            }

            return(new UserManagerResponse
            {
                Message = "Role name is already exists,",
                IsSuccess = false
            });
        }
예제 #10
0
        /// <summary>
        /// Returns the entity holding the access control based on the cmdlet parameters.
        /// Entity will be of the form user-userId, user-emailAddress, group-groupId,
        /// group-emailAddress, project-role-projectNumber, allUsers or allAuthenticatedUsers.
        /// </summary>
        protected string GetAclEntity()
        {
            switch (ParameterSetName)
            {
            case ParameterSetNames.User:
                return($"user-{User}");

            case ParameterSetNames.Group:
                return($"group-{Group}");

            case ParameterSetNames.Domain:
                return($"domain-{Domain}");

            case ParameterSetNames.Project:
                return($"project-{ProjectRole.ToLower()}-{ProjectNumber}");

            case ParameterSetNames.AllUsers:
                return("allUsers");

            case ParameterSetNames.AllAuthenticatedUsers:
                return("allAuthenticatedUsers");

            default:
                throw UnknownParameterSetException;
            }
        }
예제 #11
0
        private ProjectRole[] GenerateRoles()
        {
            ProjectRole[] _roles = new ProjectRole[] {
                new ProjectRole()
                {
                    RoleName = "Admin"
                },
                new ProjectRole()
                {
                    RoleName = "Owner"
                },
                new ProjectRole()
                {
                    RoleName = "Manager"
                },
                new ProjectRole()
                {
                    RoleName = "Salesman"
                },
                new ProjectRole()
                {
                    RoleName = "Operator"
                }
            };

            return(_roles);
        }
예제 #12
0
        public IActionResult Assign(int personId, int projectId)
        {
            //Declaire a new project object
            ProjectRole projectRole = new ProjectRole();

            //Read in all the roles
            var roles = _roleRepo.ReadAll();

            //Set the PR person and project ids.
            projectRole.PersonId  = personId;
            projectRole.ProjectId = projectId;

            //Loop through the roles to the member role
            foreach (var each in roles)
            {
                if (each.Name.Equals("Member"))
                {
                    //Add the member role id to the PR object
                    projectRole.RoleId = each.Id;
                }
            }

            //Make sure we have done something with our PR
            if (projectRole != null)
            {
                //Create the PR and redirect.
                _projectRoleRepo.Create(projectRole);
                return(RedirectToAction("Details", "Projects", new { id = projectRole.ProjectId }));
            }

            return(View());
        }
예제 #13
0
        public ActionResult DeleteConfirmed(int id)
        {
            ProjectRole projectRole = db.ProjectRoles.Find(id);

            db.ProjectRoles.Remove(projectRole);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #14
0
 public static ConditionOption CreateConditionOption(
     string name,
     ProjectRole assignedRole,
     Condition condition,
     string value = null)
 {
     return(new ConditionOption(condition.Task, name, assignedRole, condition, value));
 }
 //Assign a person to a project with a role
 public void AssignToProject(ProjectRole pr)
 {
     _db.ProjectRoles.Add(pr);
     pr.Project.Roles.Add(pr);
     _db.Entry(pr.Project).State = EntityState.Modified;
     pr.Person.Roles.Add(pr);
     _db.Entry(pr.Person).State = EntityState.Modified;
     _db.SaveChanges();
 }
 //Remove a person from a project
 public void RemoveFromProject(ProjectRole projectRole)
 {
     projectRole.Project.Roles.Remove(projectRole);
     _db.Entry(projectRole.Project).State = EntityState.Modified;
     projectRole.Person.Roles.Remove(projectRole);
     _db.Entry(projectRole.Person).State = EntityState.Modified;
     _db.ProjectRoles.Remove(projectRole);
     _db.SaveChanges();
 }
예제 #17
0
        public ProjectRole Update(ProjectRole projRole)
        {
            using (var ctx = new WcfEntityContext())
            {
                ctx.AttachModify("ProjectRoles", projRole);

                return projRole;
            }
        }
        private ProjectGroupRole AddGroupRole(ProjectGroup projectGroup, ProjectRole projectRole)
        {
            var projectGroupRole = new ProjectGroupRole();

            projectGroupRole.ProjectGroup = projectGroup;
            projectGroupRole.ProjectRole  = projectRole;
            Repository.Add(projectGroupRole);
            return(projectGroupRole);
        }
예제 #19
0
 public IActionResult Edit(ProjectRole projectRole)
 {
     if (ModelState.IsValid)
     {
         _projectRoles.Update(projectRole.Id, projectRole);
         return(RedirectToAction("Index"));
     }
     return(View(projectRole));
 }
예제 #20
0
        public ProjectRole Update(ProjectRole projRole)
        {
            using (var ctx = new WcfEntityContext())
            {
                ctx.AttachModify("ProjectRoles", projRole);

                return(projRole);
            }
        }
        private ProjectUserRole AddUserRole(ProjectUser projectUser, ProjectRole projectRole)
        {
            var projectUserRole = new ProjectUserRole();

            projectUserRole.ProjectUser = projectUser;
            projectUserRole.ProjectRole = projectRole;
            Repository.Add(projectUserRole);
            return(projectUserRole);
        }
예제 #22
0
 public static Process CreateProcess(
     Task task,
     string name,
     ProjectRole assignedRole,
     string description = null,
     FormView formView  = null)
 {
     return(new Process(task, name, assignedRole, description, formView));
 }
예제 #23
0
 public async Task<IActionResult> Create(ProjectRole role)
 {
     var roleExist = await roleManager.RoleExistsAsync(role.RoleName);
     if(!roleExist)
     {
         var result = await roleManager.CreateAsync(new IdentityRole(role.RoleName));
     }
     return View();
 }
예제 #24
0
 public static Condition CreateCondition(
     Task task,
     string name,
     ProjectRole assignedRole,
     string variableName = null,
     string description  = null,
     FormView formView   = null)
 {
     return(new Condition(task, name, assignedRole, variableName, description, formView));
 }
        /// <summary>
        /// Initializes a new instance of the AdjustAllocationEvent class.
        /// </summary>
        /// <param name="personId">The id of the person.</param>
        /// <param name="projectId">The id of the project.</param>
        /// <param name="percentage">The percent of the person's capacity this project will receive.</param>
        /// <param name="role">This person's role on the project.</param>
        public AdjustAllocationActionData(int personId, int projectId, decimal percentage, ProjectRole role)
        {
            PersonId = personId;

            ProjectId = projectId;

            Percentage = percentage;

            Role = role;
        }
예제 #26
0
        public void ChangeProjectRoleName(int projectRoleId, string projectRoleName)
        {
            ProjectRole role = db.ProjectRoles.Find(projectRoleId);

            if (role == null)
            {
                throw new NotFoundException();
            }
            role.ProjectRoleName = projectRoleName;
        }
예제 #27
0
        public void DeleteProjectRole(int id)
        {
            ProjectRole projectrole = db.ProjectRoles.Find(id);

            if (projectrole == null)
            {
                throw new NotFoundException();
            }
            db.ProjectRoles.Remove(projectrole);
        }
예제 #28
0
        public void AssignProject(int id, ProjectRole pr)
        {
            var role = Read(id);

            if (role != null)
            {
                role.ProjectRoles.Add(pr);
                Update(0, role);
            }
        }
예제 #29
0
        public ActionResult Create(ProjectRole projectRole)
        {
            if (ModelState.IsValid)
            {
                _projectRoleService.Add(projectRole);
                return(RedirectToAction("Index"));
            }

            return(View(projectRole));
        }
예제 #30
0
        public void AssignProject(int id, ProjectRole pr)
        {
            var project = Read(id);

            if (project != null)
            {
                project.ProjectRoles.Add(pr);
                Update(0, project);
            }
        }
예제 #31
0
 public string DeleteProjectRole(int id)
 {
     using (UnitOfWork unitOfWork = new UnitOfWork(masterContext))
     {
         ProjectRole projectRole = unitOfWork.GetRepository <ProjectRole>().Get(id);
         unitOfWork.GetRepository <ProjectRole>().Delete(projectRole);
         unitOfWork.SaveChange();
     }
     return("ProjectRole silme başarılı");
 }
        public ProjectRoleDTO CreateProjectRole(string projectRoleName)
        {
            ProjectRole projectRole = new ProjectRole
            {
                ProjectRoleName = projectRoleName
            };
            var pr = Database.ProjectRoles.CreateProjectRole(projectRole);

            Database.Save();
            return(Map.ObjectMap(pr));
        }
예제 #33
0
        public ProjectRole Create(ProjectRole projRole)
        {
            using (var ctx = new WcfEntityContext())
            {
                ctx.ProjectRole.AddObject(projRole);

                ctx.SaveChanges();

                return projRole;
            }
        }
예제 #34
0
        public void Delete(ProjectRole projRole)
        {
            using (var ctx = new WcfEntityContext())
            {
                var entityToDelete = ctx.ProjectRole.Where(p => p.ProjectId == projRole.ProjectId
                                                           && p.UserId == projRole.UserId
                                                           && p.RoleId == projRole.RoleId).SingleOrDefault();

                ctx.ProjectRole.DeleteObject(entityToDelete);
                ctx.SaveChanges();
            }
        }
예제 #35
0
 public void AdjustAllocation(Company company, Employee employee, Project project, decimal percentage, ProjectRole role)
 {
     throw new NotImplementedException();
 }