Пример #1
0
 public ActionResult AddMember(MemberManagerViewModel memberManagerViewModel)
 {
     var jsonResult = new JsonResult();
     try
     {
         var user = _userLogic.GetByUserName(memberManagerViewModel.UserName);
         if (user == null)
         {
             user=new User
                 {
                     UserName = memberManagerViewModel.UserName,
                     Password = UserConfig.InitialPassword,
                     Email = memberManagerViewModel.UserName+UserConfig.InitialEmailExt
                 };
             _userLogic.Register(user);
             user = _userLogic.GetByUserName(user.UserName);
         }
         if (_userProjectRoleRelationLogic.GetByUserIdAndProjectId(user.UserId, memberManagerViewModel.ProjectId)==null)
         {
             var userProjectRoleRelation = new UserProjectRoleRelation
                 {
                     UserId = user.UserId,
                     ProjectId = memberManagerViewModel.ProjectId,
                     RoleId = memberManagerViewModel.RoleId
                 };
             _userProjectRoleRelationLogic.Add(userProjectRoleRelation);
         }
         jsonResult.Data = new { IsSuccess = true };
     }
     catch (Exception)
     {
         jsonResult.Data = new { IsSuccess = false, ErrorMessage = "Add failed" };
     }
     return jsonResult;
 }
 public void Update(UserProjectRoleRelation userProjectRoleRelation)
 {
     var single = GetByUserIdAndProjectId(userProjectRoleRelation.UserId, userProjectRoleRelation.ProjectId);
     single.RoleId = userProjectRoleRelation.RoleId;
     _bugTrackDbContext.SaveChanges();
 }
 public void Delete(UserProjectRoleRelation userProjectRoleRelation)
 {
     var single = GetByUserIdAndProjectId(userProjectRoleRelation.UserId, userProjectRoleRelation.ProjectId);
     _bugTrackDbContext.UserProjectRoleRelations.Remove(single);
 }
 public void Add(UserProjectRoleRelation userProjectRoleRelation)
 {
     _bugTrackDbContext.UserProjectRoleRelations.Add(userProjectRoleRelation);
     _bugTrackDbContext.SaveChanges();
 }
 public void Update(UserProjectRoleRelation userProjectRoleRelation)
 {
     _userProjectRoleRelationRepository.Update(userProjectRoleRelation);
 }
 public void Delete(UserProjectRoleRelation userProjectRoleRelation)
 {
     _userProjectRoleRelationRepository.Delete(userProjectRoleRelation);
 }
 public void Add(UserProjectRoleRelation userProjectRoleRelation)
 {
     _userProjectRoleRelationRepository.Add(userProjectRoleRelation);
 }
Пример #8
0
 public ActionResult CreateProject(CreateProjectViewModel createProjectViewModel)
 {
     try
     {
         var project = new Project
         {
             ProjectName = createProjectViewModel.ProjectName,
             Description = createProjectViewModel.Description,
             CreateDate = DateTime.Now,
             Sole = Guid.NewGuid()
         };
         var userId = _cookieHelper.GetUserId(Request);
         _projectLogic.CreateProject(project);
         var projectId = _projectLogic.Get(project.ProjectName,project.Sole).ProjectId;
         var userProjectRoleRelation=new UserProjectRoleRelation
             {
                 ProjectId = projectId,
                 UserId = userId,
                 RoleId = RoleConfig.Creator
             };
         _userProjectRoleRelationLogic.Add(userProjectRoleRelation);
         return new RedirectResult(Url.Action("Index", "Project"));
     }
     catch
     {
         return View("Error");
     }
 }
Пример #9
0
        public ActionResult UpdateRelation(MemberListViewModel memberListViewModel)
        {
            var jsonResult = new JsonResult();
            try
            {
                var userProjectRoleRelation=new UserProjectRoleRelation
                    {
                        UserId = memberListViewModel.UserId,
                        ProjectId = memberListViewModel.ProjectId,
                        RoleId = memberListViewModel.RoleId
                    };
                _userProjectRoleRelationLogic.Update(userProjectRoleRelation);
                jsonResult.Data = new { IsSuccess = true };

            }
            catch (Exception)
            {
                jsonResult.Data = new {IsSuccess = false};
            }
            return jsonResult;
        }