/// <summary> /// returns accessright for user to an issue /// </summary> /// <param name="userId"></param> /// <param name="issueId"></param> /// <returns></returns> public AccessRightModel AccessRightOfUserForIssue(int userId, int issueId) { AccessRightModel arm = new AccessRightModel(); AccessRightModel ar = arm.ToModel(AccessRightOp.AccessRightOfUserForIssue(userId, issueId)); return(ar); }
/// <summary> /// gets access right for iser of issue /// </summary> /// <param name="issueId">issue id</param> /// <param name="userId">user id</param> /// <returns>AccessRightModel</returns> public AccessRightModel GetAccessRight(int issueId, int userId) { AccessRightModel arm = new AccessRightModel(); arm = arm.ToModel(AccessRightOp.GetAccessRight(issueId, userId)); arm.SelfAssessmentHistory = GetSelfAssessmentHistoryForAr(userId, issueId); return(arm); }
/// <summary> /// updates accessrights which user modified /// </summary> /// <param name="addedAr">new granted permissions</param> /// <param name="deletedAr">removed permissions</param> /// <param name="updatedAr">updated permissions</param> /// <param name="issueId">Issue for permissions</param> /// <param name="userId">user who is making changes</param> public void UpdateAccessRights(List <AccessRightModel> addedAr, List <AccessRightModel> deletedAr, List <AccessRightModel> updatedAr, int issueId, int userId) { AccessRightModel arm = new AccessRightModel(); List <AccessRight> dList = arm.ToEntityList(deletedAr); List <AccessRight> aList = arm.ToEntityList(addedAr); List <AccessRight> uList = null; if (updatedAr != null) { uList = arm.ToEntityList(updatedAr).Except(dList).Except(aList).ToList(); } AccessRightOp.UpdateRights(aList, dList, uList, issueId, userId); }
public ActionResult Index(AccessRightModel arModel) { ResultModel result = new ResultModel(); try { result.IsSuccess = AccessRightBLWithTran.EditModuleAccessRight(arModel.ModuleActions, arModel.SelectedGroupID); } catch (Exception e) { result.Exception = e.Message; result.IsSuccess = false; } return(Json(result)); }
public HttpResponseMessage RemoveAccessRight(AccessRightModel accessRight) { HttpResponseMessage msg = new HttpResponseMessage(); IssueCreating ic = new IssueCreating(); if (ic.RemoveAccessRight(accessRight, GetUserIdFromClaim())) { msg.StatusCode = System.Net.HttpStatusCode.OK; var context = GlobalHost.ConnectionManager.GetHubContext <NotificationHub>(); context.Clients.All.userRemovedFromIssue(accessRight.IssueId, accessRight.UserId, GetUserIdFromClaim()); } else { msg.StatusCode = System.Net.HttpStatusCode.InternalServerError; } return(msg); }
/// <summary> /// returns list of access right by IssueId /// </summary> /// <param name="issueId"></param> /// <returns>Accessright with UserId and full Username</returns> public List <AccessRightModel> GetAccessRightsOfIssue(int issueId) { List <AccessRightModel> list = new List <AccessRightModel>(); List <AccessRight> arEntityList = AccessRightOp.GetAccessRightsForIssue(issueId); string right; string name; AccessRightModel arm; foreach (AccessRight ar in arEntityList) { right = ar.Right; switch (right) { case "O": right = "Owner"; break; case "C": right = "Contributor"; break; case "V": right = "Viewer"; break; } arm = new AccessRightModel(); arm = arm.ToModel(ar); arm.Right = right; arm.SelfAssessmentHistory = GetSelfAssessmentHistoryForAr(ar.UserId, issueId); if (userList == null) { list.Add(arm); } else { arm.Name = userList.Find(x => x.Id == arm.UserId).FirstName + " " + userList.Find(x => x.Id == arm.UserId).LastName; list.Add(arm); } } return(list); }
/// <summary> /// Get all module accessright by groupID (if groupID is null,get the first one in groupList) /// </summary> /// <param name="groupID"></param> /// <returns></returns> public AccessRightModel GetAllAccessRight(string groupID) { string selectedGroupID = ""; string selectedGroupName = ""; AccessRightModel arModel = new AccessRightModel(); //get group list List <GroupM> groupList = GetAllGroup(groupID, out selectedGroupID, out selectedGroupName); arModel.GroupList = groupList; arModel.SelectedGroupID = selectedGroupID; arModel.SelectedGroupName = selectedGroupName; //get module access right if (groupList.Count > 0) { List <string> allowAccessActionList = GetModuleAccessRightByGroupID(selectedGroupID); //get allow action of the selected group List <ModuleRightModel> moduleRightList = GetAllModule(allowAccessActionList); //get all module and all accessright info arModel.ModuleRightList = moduleRightList; } return(arModel); }
/// <summary> /// MVC get action for define issue view (Creating.cshtml) /// </summary> /// <param name="issueId">usually issue id of issue to be shown, but if issue id equals -1 then view for new issue is prepared</param> /// <returns>define issue vies (Creating.cshtml)</returns> public ActionResult Creating(int issueId) { CreatingVM vm = new CreatingVM(); IssueCreating ic = new IssueCreating(); int userId = GetUserIdFromClaim(); vm.AllTags = ic.GetAllTags(); vm.Issues = new List <IssueShort>(); vm.Issues.Add(new IssueShort(-1, "none")); vm.Issues.AddRange(ic.GetUserIssuesShort(userId)); vm.AllUsers = ic.GetAllUsers(); vm.UserId = userId; //existing issue if (issueId != -1) { vm.Issue = ic.GetIssue(issueId); vm.AccessRights = ic.GetAccessRightsOfIssue(issueId); AccessRightModel arm = ic.AccessRightOfUserForIssue(userId, issueId); vm.AccessRight = arm.Right; vm.SelfAssessmentDescription = arm.SelfAssessmentDescr; vm.SelfAssessmentValue = Convert.ToInt32(arm.SelfAssessmentValue); vm.Comments = ic.GetIssueComments(issueId, userId); vm.GroupthinkNotifications = ic.GetGroupthinkNotifications(issueId, userId); vm.GroupshiftProperties = ic.GetGropshiftProperties(issueId); if (ic.MarkAsRead(issueId, userId)) //try to makr issue as read for user { var ctx2 = GlobalHost.ConnectionManager.GetHubContext <NotificationHub>(); ctx2.Clients.All.updateActivity(issueId, userId); } vm.UserWithMostChanges = ic.UserWithMostChanges(issueId); if (vm.AccessRight == "O") // specific inits for issue owner { vm.AllUserChangeCounts = ic.GetAllChangeCountsByUser(issueId); vm.GroupActivity = ic.GetGroupActivity(issueId); vm.GroupTrustworthiness = ic.GetGroupTrustworthiness(issueId); vm.DecisionTrustworthiness = ic.GetDecisionTrustworthiness(issueId); } else // inits for other users { vm.AllUserChangeCounts = new List <KeyValuePair <UserShortModel, int> >(); vm.GroupActivity = new List <KeyValuePair <string, int> >(); vm.GroupTrustworthiness = new List <string>(); vm.DecisionTrustworthiness = new List <string>(); } vm.UserChangesCount = ic.GetUserChangesCount(issueId, userId); vm.InfoCount = ic.GetInfoCountForUser(issueId, userId); vm.ReadInfoCount = ic.GetReadInfoCountForUser(issueId, userId); vm.UnreadInformation = ic.GetUnreadInformation(issueId, userId); vm.UserChanges = ic.GetUserChanges(issueId, userId); vm.LastChange = ic.GetLastChange(issueId); vm.Last100Changes = ic.GetLast100Changes(issueId); } else // new issue { vm.Issue = new IssueModel(); vm.Issue.Status = "CREATING"; vm.Issue.Setting = "A"; vm.Issue.AnonymousPosting = false; vm.AccessRights = new List <AccessRightModel>(); vm.AccessRights.Add(new AccessRightModel(userId, "Owner", vm.AllUsers.Where(x => x.Id == userId).FirstOrDefault().Name)); vm.AccessRight = "O"; vm.Issue.Id = -1; vm.Comments = new List <CommentModel>(); vm.GroupthinkNotifications = new List <NotificationModel>(); vm.GroupshiftProperties = new List <KeyValuePair <string, List <string> > >(); vm.InfoCount = 0; vm.ReadInfoCount = 0; vm.UserChangesCount = 0; vm.UserChanges = new List <UserChangeModel>(); vm.UnreadInformation = new List <KeyValuePair <string, int> >(); vm.Last100Changes = new List <UserChangeModel>(); vm.LastChange = new UserChangeModel(); vm.GroupActivity = new List <KeyValuePair <string, int> >(); vm.GroupTrustworthiness = new List <string>(); vm.DecisionTrustworthiness = new List <string>(); } vm.AllUsers = vm.AllUsers.Where(x => x.Id != userId).ToList(); UserShortModel rmUser; foreach (AccessRightModel arm in vm.AccessRights) { rmUser = vm.AllUsers.Where(x => x.Id == arm.UserId).FirstOrDefault(); vm.AllUsers.Remove(rmUser); } vm.AllUsers.Insert(0, new UserShortModel(0, "", "")); return(View(vm)); }
/// <summary> /// removes an accessright from issue /// </summary> /// <param name="accessRight"></param> /// <param name="userId"></param> /// <returns></returns> public bool RemoveAccessRight(AccessRightModel accessRight, int userId) { AccessRightModel arm = new AccessRightModel(); return(AccessRightOp.RemoveAccessRight(arm.ToEntity(accessRight), userId)); }