public async Task <IActionResult> Create([Bind("Grp_id,Grp_Name,Grp_Member,Grp_Admin")] GroupDetails groupDetails, string[] Grp_Member) { if (ModelState.IsValid) { if (_context.GroupDetails.Any(name => name.Grp_Name.Equals(groupDetails.Grp_Name))) { ModelState.AddModelError(string.Empty, "Group is already exists"); } else { string GrpMemebr = ""; foreach (var item in Grp_Member) { GrpMemebr += item.ToString() + ","; } GrpMemebr += _userManager.GetUserName(User); groupDetails.Grp_Member = GrpMemebr; groupDetails.Grp_Admin = _userManager.GetUserName(User); _context.Add(groupDetails); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } } List <UserList> lstusers = UserLists(); ViewData["Email"] = new SelectList(lstusers, "UserId", "User_Name"); return(View(groupDetails)); }
public int AddDelegateGroup( int centreId, string groupLabel, string?groupDescription, int adminUserId, int linkedToField = 0, bool syncFieldChanges = false, bool addNewRegistrants = false, bool populateExisting = false ) { var groupDetails = new GroupDetails { CentreId = centreId, GroupLabel = groupLabel, GroupDescription = groupDescription, AdminUserId = adminUserId, CreatedDate = clockService.UtcNow, LinkedToField = linkedToField, SyncFieldChanges = syncFieldChanges, AddNewRegistrants = addNewRegistrants, PopulateExisting = populateExisting, }; return(groupsDataService.AddDelegateGroup(groupDetails)); }
public static bool IsGroupStarted(string group) { if (string.IsNullOrWhiteSpace(group)) { return(false); } GroupDetails details = null; try { Guard.EnterReadLock(); if (!GroupMap.TryGetValue(group, out details)) { return(false); } } finally { Guard.ExitReadLock(); } // non-guarded access return(details.IsStarted); }
private void lvwGroups_SelectedIndexChanged(object sender, EventArgs e) { foreach (Control c in pnlGroupDetail.Controls) { c.Dispose(); } pnlGroupDetail.Controls.Clear(); if (lvwGroups.SelectedItems.Count == 1) { try { DirectoryManager.GroupSearchData g = (DirectoryManager.GroupSearchData)lvwGroups.SelectedItems[0].Tag; GroupDetails grpPanel = new GroupDetails(instance, new Group() { ID = g.GroupID, Name = g.GroupName }) { Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right }; grpPanel.Region = new System.Drawing.Region( new System.Drawing.RectangleF( grpPanel.tpGeneral.Left, grpPanel.tpGeneral.Top, grpPanel.tpGeneral.Width, grpPanel.tpGeneral.Height)); pnlGroupDetail.Controls.Add(grpPanel); } catch { } } }
public async Task SendStartGame(string group, int timeoutseconds, string seperator, string words) { try { // set the owner GroupDetails.SetOwner(group, Context.ConnectionId); // add words if (!GroupDetails.AddRoundDetails(group, words.Split(seperator), timeoutseconds)) { await Clients.Group(group).SendAsync("ReceiveMessage", "failed to set game details"); return; } // mark that this group has already started if (!GroupDetails.SetGroupStarted(group, isstarted: true)) { await Clients.Group(group).SendAsync("ReceiveMessage", $"failed to start game"); return; } // notify everyone else to start game await Clients.OthersInGroup(group).SendAsync("ReceiveStartGame"); } catch (Exception e) { await Clients.Group(group).SendAsync("ReceiveMessage", $"failed to start game: {e.Message}"); } }
private void WriteGroupDetails(DeviceGroup group)// throws IOException { GroupDetails groupDetails = new GroupDetails { }; groupDetails.Id = ByteString.CopyFrom(group.Id); if (group.Name != null) { //groupDetails.Name = group.getName().Match(e => e, () => { throw new Exception(); }); } if (group.Avatar != null) { //GroupDetails.Types.GroupAvatar avatarBuilder = new GroupDetails.Types.GroupAvatar { }; //SignalServiceAttachmentStream avatar = group.getAvatar().Match(e => e, () => { throw new Exception(); }); //avatarBuilder.ContentType = avatar.C; //avatarBuilder.Length = (uint)avatar.Length; //groupDetails.Avatar = avatarBuilder; } //if (group.ExpirationTimer groupDetails.Members.AddRange(group.Members); //groupDetails.Active = group.Active; byte[] serializedContactDetails = groupDetails.ToByteArray(); writeVarint32(serializedContactDetails.Length); output.Write(serializedContactDetails, 0, serializedContactDetails.Length); }
protected void Page_Load(object sender, EventArgs e) { using (con) { con.Open(); string str = ("select assign_g_id from assignvalue where no = 1"); MySqlCommand cmd = new MySqlCommand(str, con); MySqlDataReader sdr = cmd.ExecuteReader(); sdr.Read(); int temp = sdr.GetInt32(0); sdr.Close(); string username = Session["username"].ToString(); // str = "select prn from student where username = '******'"; //cmd = new MySqlCommand(str, con); // sdr = cmd.ExecuteReader(); //sdr.Read(); // int prn = sdr.GetInt32(0); // sdr.Close(); str = "update student set g_id='" + temp + "' where username = '******'"; cmd = new MySqlCommand(str, con); cmd.ExecuteNonQuery(); str = "select S_nm, PRN, g_id from student where g_id = " + temp + ""; MySqlDataAdapter sda = new MySqlDataAdapter(str, con); DataTable dtb1 = new DataTable(); sda.Fill(dtb1); GroupDetails.DataSource = dtb1; GroupDetails.DataBind(); } }
/// <summary> /// This method returns specific group details /// </summary> /// <param name="groupId"></param> /// <returns></returns> public GroupDetails GetGroup(int groupId) { Group group = db.Groups.Find(groupId); if (group == null) { throw new ArgumentNullException("Group not found"); } GroupDetails groupDetails = null; /* * try * { * groupDetails = new GroupDetails(); * groupDetails.group = group; * groupDetails.UserList = new List<UserDetails>(); * string[] users = group.user_ids.Split(','); * * foreach (var userId in users) * { * User user = db.Users.Find(Int32.Parse(userId)); * * groupDetails.UserList.Add(new UserDetails() { Id = user.id, Name = user.name }); * } * } * catch (Exception) * { * * throw; * }*/ return(groupDetails); }
public static bool TryGetHasAnswered(string group, string connectionid, out bool hasanswered) { hasanswered = false; if (string.IsNullOrWhiteSpace(group) || string.IsNullOrWhiteSpace(connectionid)) { return(false); } GroupDetails details = null; try { Guard.EnterReadLock(); if (!GroupMap.TryGetValue(group, out details)) { return(false); } } finally { Guard.ExitReadLock(); } try { details.InstanceGuard.EnterReadLock(); hasanswered = details.HasAnswered.Contains(connectionid); return(true); } finally { details.InstanceGuard.ExitReadLock(); } }
public static GroupDetails GetOrCreateGroup(string group) { try { ConnectionsLock.EnterUpgradeableReadLock(); GroupDetails groupdetails = null; if (!Connections.TryGetValue(group, out groupdetails)) { try { ConnectionsLock.EnterWriteLock(); if (!Connections.TryGetValue(group, out groupdetails)) { groupdetails = new GroupDetails(groupname: group); Connections.Add(group, groupdetails); } } finally { ConnectionsLock.ExitWriteLock(); } } return(groupdetails); } finally { ConnectionsLock.ExitUpgradeableReadLock(); } }
public string CreateGroup(GroupDetails obj) { try { U_USR_GroupsDAL ocontactsDAL = new U_USR_GroupsDAL(); U_USR_Groups ogroup = new U_USR_Groups(); ogroup.Group_Id = Guid.NewGuid().ToString(); ogroup.Group_Name = obj.Group_Name; ogroup.Group_Source = ""; ogroup.Group_Status = "1"; ogroup.Usr_Id = obj.User_Id; ogroup.Updated_by = ""; ogroup.Updated_Date = DateTime.Now; ogroup.Created_by = ""; ogroup.Created_Date = DateTime.Now; ogroup.Group_Desc = ""; bool status = ocontactsDAL.InsertU_USR_Groups(ogroup); if (status == true) { return("1"); } else { return("0"); } } catch (Exception ex) { Console.Write(ex); return(null); } }
public Status GroupInsert(Stream jsData) { string strGetData = CommonFunctions.ReadJSON(jsData); GroupDetails objGroup = new GroupDetails(); try { objGroup = new JavaScriptSerializer().Deserialize <GroupDetails>(strGetData); objGroup.CreatedUser = UtilCipher.Decrypt(objGroup.CreatedUser.ToString()); } catch (Exception) { return(new Status() { StatusId = AppConstant.HackeAccess, MsgDesc = AppConstant.ErrorHackerMsg }); } try { return(new GroupController().Insert(objGroup)); } catch (Exception ex) { LogManager.LogMessage(ex, new MessageStructure("Group Creation", MessageSeverity.Exception)); return(new Status() { StatusId = AppConstant.Exception, MsgDesc = AppConstant.ExceptionMsg }); } }
public string CreateUserGroup(GroupDetails ouser) { try { HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(@"http://" + GeneralBLL.Service_Link + "/Services/ContactsService.svc/CreateGroup"); httpWebRequest.Method = "POST"; httpWebRequest.ContentType = @"application/json; charset=utf-8"; using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream())) { string json = new JavaScriptSerializer().Serialize(ouser); streamWriter.Write(json); } var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse(); using (var streamReader = new StreamReader(httpResponse.GetResponseStream())) { var result = streamReader.ReadToEnd(); return(result.Replace("\"", "")); } } catch (Exception ex) { return(string.Empty); } }
public async Task SendNextRound(string group) { try { // check that this is initiated by the owner if (!GroupDetails.TryGetOwner(group, out string ownerconnectionid) || !string.Equals(Context.ConnectionId, ownerconnectionid, StringComparison.OrdinalIgnoreCase)) { return; } // choose details about the next round if (!GroupDetails.StartNextRound(group, out RoundDetails round)) { await Clients.Group(group).SendAsync("ReceiveMessage", "failed to start round"); return; } // give credit for the drawer GroupDetails.AddToScore(group, round.ConnectionId, round.Timeout / 3f); GroupDetails.SetHasAnswered(group, round.ConnectionId); // notify everyone except the drawer await Clients.GroupExcept(group, round.ConnectionId).SendAsync("ReceiveNextRound", round.Username, round.Timeout, round.ObfuscatedWord, false /* candraw */); // notify the drawer await Clients.Client(round.ConnectionId).SendAsync("ReceiveNextRound", round.Username, round.Timeout, round.Word, true /* candraw */); } catch (Exception e) { await Clients.Group(group).SendAsync("ReceiveMessage", $"failed to start next round: {e.Message}"); } }
private async Task SetSelectedGroupAsync(GroupDetails value) { bool canProceed = true; if (this.ActiveViewModel != null && this.ActiveViewModel.IsCheckedOut && this.isChanged) { this.ActiveViewModel.ConfirmationWindow.Raise(new Common.ConfirmationWindowViewModel(null) { Content = "Are you sure to proceed without saving?", Title = "Confirm Save - Group" }, (callBack) => { if (callBack.Confirmed == false) { canProceed = false; } }); } if (canProceed) { this.isChanged = false; await UnLockAsync(); this.SetField(ref _SelectedGroup, value, () => SelectedGroup); if (this._SelectedGroup != null) { this._SelectedGroup.ComponentPermissionChanged += this.Edit.SelectedGroup_ComponentPermissionChanged; this._SelectedGroup.ComponentPermissionChanged += () => { this.OnPropertyChanged(() => SelectedComponentPermissionOption); }; } if (value != null) { await this.OnStepAsync(EnumSteps.SelectGroup); } } }
public void NotifyMembers() { foreach (var grpMembers in GroupMembers) { grpMembers.Update(this, GroupDetails.GetNewNotification()); } }
private void writeGroupDetails(DeviceGroup group)// throws IOException { GroupDetails groupDetails = new GroupDetails { }; groupDetails.Id = ByteString.CopyFrom(group.getId()); if (group.getName().HasValue) { groupDetails.Name = group.getName().Match(e => e, () => { throw new Exception(); }); } if (group.getAvatar().HasValue) { GroupDetails.Types.Avatar avatarBuilder = new GroupDetails.Types.Avatar { }; SignalServiceAttachmentStream avatar = group.getAvatar().Match(e => e, () => { throw new Exception(); }); avatarBuilder.ContentType = avatar.getContentType(); avatarBuilder.Length = (uint)avatar.getLength(); groupDetails.Avatar = avatarBuilder; } groupDetails.Members.AddRange(group.getMembers()); groupDetails.Active = group.isActive(); byte[] serializedContactDetails = groupDetails.ToByteArray(); writeVarint32(serializedContactDetails.Length); output.Write(serializedContactDetails, 0, serializedContactDetails.Length); }
public IHttpActionResult Post(CreateGroupDetailsWithStudentsDTO groupDetailsDto) { if (!ModelState.IsValid) { return(BadRequest()); } try { GroupDetails groupDetails = new GroupDetails(); groupDetails.GroupName = groupDetailsDto.GroupName; groupDetails.ClassID = groupDetailsDto.ClassID; groupDetails.CreatioinDate = DateTime.UtcNow; _unitOfWork.GroupsDetails.Add(groupDetails); _unitOfWork.Complete(); if (groupDetailsDto.studentIDs != null) { foreach (int studentID in groupDetailsDto.studentIDs) { GroupStudentMapping groupStudentMap = new GroupStudentMapping(); groupStudentMap.GroupID = groupDetails.GroupID; groupStudentMap.studID = studentID; _unitOfWork.GroupStudentMappings.Add(groupStudentMap); _unitOfWork.Complete(); } } return(Created(new Uri(Request.RequestUri + "/" + groupDetails.GroupID), groupDetails)); } catch (Exception ex) { return(InternalServerError(ex)); } }
public static bool TryGetOwner(string group, out string ownerconnectionid) { ownerconnectionid = ""; if (string.IsNullOrWhiteSpace(group)) { return(false); } GroupDetails details = null; try { Guard.EnterReadLock(); if (!GroupMap.TryGetValue(group, out details)) { return(false); } } finally { Guard.ExitReadLock(); } // non-guared access ownerconnectionid = details.OwnerConnectionId; return(true); }
public static bool SetInRound(string group, bool inround) { if (string.IsNullOrWhiteSpace(group)) { return(false); } GroupDetails details = null; try { Guard.EnterReadLock(); if (!GroupMap.TryGetValue(group, out details)) { return(false); } } finally { Guard.ExitReadLock(); } // non-guarded access details.InRound = inround; return(true); }
public ActionResult P_EditGroups(string Id) { ContactsBLL ocntsBLL = new ContactsBLL(); GroupDetails obj = new GroupDetails(); obj.Group_Id = Id; return(PartialView("_EditGroup", obj)); }
private void AddGroupMessageinCache(GroupDetails _GroupDetails) { GroupMessages.Add(_GroupDetails); if (GroupMessages.Count > 100) { GroupMessages.RemoveAt(0); } }
public void AddDelegateGroup_sets_GroupDetails_correctly() { // Given var timeNow = DateTime.UtcNow; GivenCurrentTimeIs(timeNow); var groupDetails = new GroupDetails { CentreId = 101, GroupLabel = "Group name", GroupDescription = "Group description", AdminUserId = 1, CreatedDate = timeNow, LinkedToField = 1, SyncFieldChanges = true, AddNewRegistrants = true, PopulateExisting = true, }; const int returnId = 1; A.CallTo(() => groupsDataService.AddDelegateGroup(A <GroupDetails> ._)).Returns(returnId); // When var result = groupsService.AddDelegateGroup( groupDetails.CentreId, groupDetails.GroupLabel, groupDetails.GroupDescription, groupDetails.AdminUserId, groupDetails.LinkedToField, groupDetails.SyncFieldChanges, groupDetails.AddNewRegistrants, groupDetails.PopulateExisting ); // Then using (new AssertionScope()) { result.Should().Be(returnId); A.CallTo( () => groupsDataService.AddDelegateGroup( A <GroupDetails> .That.Matches( gd => gd.CentreId == groupDetails.CentreId && gd.GroupLabel == groupDetails.GroupLabel && gd.GroupDescription == groupDetails.GroupDescription && gd.AdminUserId == groupDetails.AdminUserId && gd.CreatedDate == groupDetails.CreatedDate && gd.LinkedToField == groupDetails.LinkedToField && gd.SyncFieldChanges == groupDetails.SyncFieldChanges && gd.AddNewRegistrants == groupDetails.AddNewRegistrants && gd.PopulateExisting == groupDetails.PopulateExisting ) ) ).MustHaveHappenedOnceExactly(); } }
public ActionResult P_DeleteGroups(string Id, string Name) { ContactsBLL ocntsBLL = new ContactsBLL(); GroupDetails obj = new GroupDetails(); obj.Group_Id = Id; obj.Group_Name = Name; return(PartialView("_DeleteGroup", obj)); }
private void WriteGroupDetails(DeviceGroup group) { GroupDetails groupDetails = new GroupDetails(); groupDetails.Id = ByteString.CopyFrom(group.Id); if (group.Name != null) { groupDetails.Name = group.Name; } if (group.Avatar != null) { GroupDetails.Types.Avatar avatarBuilder = new GroupDetails.Types.Avatar(); avatarBuilder.ContentType = group.Avatar.ContentType; avatarBuilder.Length = (uint)group.Avatar.Length; groupDetails.Avatar = avatarBuilder; } if (group.ExpirationTimer.HasValue) { groupDetails.ExpireTimer = group.ExpirationTimer.Value; } if (group.Color != null) { groupDetails.Color = group.Color; } List <GroupDetails.Types.Member> members = new List <GroupDetails.Types.Member>(group.Members.Count); foreach (SignalServiceAddress address in group.Members) { GroupDetails.Types.Member builder = new GroupDetails.Types.Member(); if (address.Uuid.HasValue) { builder.Uuid = address.Uuid.Value.ToString(); } if (address.GetNumber() != null) { builder.E164 = address.GetNumber(); } members.Add(builder); } groupDetails.Members.AddRange(members); groupDetails.Active = group.Active; groupDetails.Blocked = group.Blocked; byte[] serializedContactDetails = groupDetails.ToByteArray(); WriteVarint32(serializedContactDetails.Length); output.Write(serializedContactDetails, 0, serializedContactDetails.Length); }
public async Task SendMessage(string group, string message) { if (string.IsNullOrWhiteSpace(message)) { return; } // todo there is a corner case with only 1 player where the end will not end by answering the right answer // the reason is that the round is over but the detection logic does not catch that try { // get username GroupDetails.TryGetUsername(group, Context.ConnectionId, out string username); // check if we are in a round, and if so then check if this is a valid guess GroupDetails.TryGetInRound(group, out bool inround, out bool atendofround, out RoundDetails round); if (inround && round != null) { // check if this guess is currect if (message.IndexOf(round.Word, StringComparison.OrdinalIgnoreCase) >= 0) { // cannot guess for your own question or if you have already gotten it right if (!atendofround) { if (GroupDetails.TryGetHasAnswered(group, Context.ConnectionId, out bool answered) && !answered) { // give credit GroupDetails.AddToScore(group, Context.ConnectionId, (float)(round.End - DateTime.UtcNow).TotalSeconds); // mark that you answered GroupDetails.SetHasAnswered(group, Context.ConnectionId); } // check again GroupDetails.TryGetInRound(group, out inround, out atendofround, out round); } // remove the correct word from the phrase message = message.Replace(round.Word, "correct :)", StringComparison.OrdinalIgnoreCase); } } // send the message to everyone in this group await Clients.Group(group).SendAsync("ReceiveMessage", $"{username}: {message}"); // finish early if done if (atendofround) { await SendRoundComplete(group); } } catch (Exception e) { await Clients.Group(group).SendAsync("ReceiveMessage", $"failed to send message: {e.Message}"); } }
public GroupList GetGroup(int userId) { DbParameter[] parameter = { DataParameter.GetSqlParam(dbUserEnity.CustomerID.ToString(), SqlDbType.Int, 50, userId, ParameterDirection.Input), }; try { GroupList objGroupList = new GroupList(); var drUserDetails = CommonDBFunctions.ExecuteDataSet(spUser.spUserLogin.ToString(), parameter); if (drUserDetails.Tables.Count > 0) { // new Status() { StatusId = AppConstant.Success, MsgDesc = success }; if (drUserDetails.Tables.Count == 1) { if (drUserDetails.Tables[1].Rows.Count > 0) { objGroupList.status = new Status() { StatusId = AppConstant.Success, MsgDesc = AppConstant.SuccessMsg }; } else { objGroupList.status = new Status() { StatusId = AppConstant.Information, MsgDesc = "No record" }; } foreach (DataRow dr in drUserDetails.Tables[1].Rows) { GroupDetails objGroup = new GroupDetails(); objGroup.GroupName = dr[dbUserEnity.FirstName.ToString()].ToString(); objGroup.StatusMsg = dr[dbUserEnity.FirstName.ToString()].ToString(); objGroup.Desc = dr[dbUserEnity.FirstName.ToString()].ToString(); objGroup.CreatedUser = dr[dbUserEnity.FirstName.ToString()].ToString(); // objGroup.Status = dr[dbUserEnity.FirstName.ToString()].ToString(); objGroup.CreatedDate = Convert.ToDateTime(dr[dbUserEnity.LastLogin.ToString()].ToString()); objGroup.GroupID = UtilCipher.Encrypt(dr[dbUserEnity.CustomerID.ToString()].ToString()); objGroup.IsAdmin = Convert.ToBoolean(dr[dbUserEnity.FirstName.ToString()]); objGroupList.groups.Add(objGroup); } } } return(objGroupList); } catch (SqlException ex) { throw ex; } }
public static bool AddUser(string group, string connectionId, string username) { if (string.IsNullOrWhiteSpace(connectionId) || string.IsNullOrWhiteSpace(group) || string.IsNullOrWhiteSpace(username)) { return(false); } GroupDetails details = null; try { Guard.EnterUpgradeableReadLock(); if (!GroupMap.TryGetValue(group, out details)) { details = new GroupDetails(); try { Guard.EnterWriteLock(); GroupMap.Add(group, details); } finally { Guard.ExitWriteLock(); } } } finally { Guard.ExitUpgradeableReadLock(); } try { details.InstanceGuard.EnterWriteLock(); if (!details.Connections.ContainsKey(connectionId)) { details.Connections.Add(connectionId, new UserDetails() { Username = username }); } else { details.Connections[connectionId].Username = username; } } finally { details.InstanceGuard.ExitWriteLock(); } return(true); }
private GroupDetails FetchGroupDetails(VoterGroup group) { var details = new GroupDetails { GroupId = group.GroupId, Average = group.Average, Count = group.AllVoters.Count }; if (group.ParentGroup != null) { details.ParentGroupId = group.ParentGroup.GroupId; } return(details); }
public static GroupDetails[] GetCachedGroupDetails() { PrxTrophyLockList(); int num = PrxTrophyGetGroupDetailsCount(); GroupDetails[] array = new GroupDetails[num]; for (int i = 0; i < num; i++) { PrxTrophyGetGroupDetails(i, out array[i]); } PrxTrophyUnlockList(); return(array); }
public void BroadCastMessage(String msgFrom, String msg, String GroupName) { var id = Context.ConnectionId; string[] Exceptional = new string[0]; Clients.Group(GroupName).sendGroupMessage(GroupName, GroupName, msg, msgFrom); GroupDetails _GroupDetail = new GroupDetails { GName = GroupName, sender = msgFrom, txt = msg }; //FromUserID = _fromUserId, FromUserName = FromUsers[0].UserName, ToUserID = _toUserId, ToUserName = ToUsers[0].UserName, Message = message }; AddGroupMessageinCache(_GroupDetail); }
private async Task SetSelectedGroupAsync(GroupDetails value) { bool canProceed = true; if (this.ActiveViewModel != null && this.ActiveViewModel.IsCheckedOut && this.isChanged) { //this.ActiveViewModel.ConfirmationWindow.Raise(new Insyston.Operations.WPF.ViewModels.Common.ConfirmationWindowViewModel(null) { Content = "Are you sure to proceed without saving?", Title = "Confirm Save - Group" }, // (callBack) => // { // if (callBack.Confirmed == false) // { // canProceed = false; // } // }); ConfirmationWindowView confirm = new ConfirmationWindowView(); ConfirmmationViewModel confirmViewModel = new ConfirmmationViewModel(); confirmViewModel.Content = "Changes have not been saved. Click OK to proceed without saving changes."; confirmViewModel.Title = "Confirm Save - Group"; confirm.DataContext = confirmViewModel; confirm.ShowDialog(); if (confirm.DialogResult == false) { canProceed = false; } else { this.isChanged = false; } } if (canProceed) { if (this.Edit.IsCheckedOut) { await this.Edit.OnStepAsync(EnumSteps.Cancel); } // Raise event to change style for hyperlink when select another record. this.ValidateNotError(); this.isChanged = false; // Just do UnLockAsync if not in mode Add. if (value != null && !value.IsNewGroup) { await UnLockAsync(); } this.SetField(ref _SelectedGroup, value, () => SelectedGroup); if (this._SelectedGroup != null) { this._SelectedGroup.ComponentPermissionChanged += this.Edit.SelectedGroup_ComponentPermissionChanged; this._SelectedGroup.ComponentPermissionChanged += () => { this.OnPropertyChanged(() => SelectedComponentPermissionOption); }; } if (value != null) { await this.OnStepAsync(EnumSteps.SelectGroup); } } }
public void GroupList_OnChanged(GroupDetails group, List<LXMUserDetail> users, List<Membership> usersList) { using (Entities model = new Entities()) { List<int> groupUsers = model.sp_GetGroupUsers(group.UserEntityId).Select(g => g.Value).ToList(); var addedUsers = usersList.Where(item => !groupUsers.Contains(item.UserId)).Select(x => x.UserId).ToList(); var currentIds = usersList.Select(item => item.UserId).ToList(); var usersInGroup = GroupFunctions.GetGroupUsers(group.UserEntityId, users); var removedUsers = usersInGroup.Where(i => !currentIds.Contains(i.UserEntityId)).Select(x => x.UserEntityId).ToList(); if (this.IsCheckedOut && (addedUsers.Count != 0 || removedUsers.Count != 0)) { this.IsChanged = true; } } }
/// <summary> /// The function used to set value for SelectedGroup when we don't want to check any business logics. /// </summary> /// <param name="value"></param> public void SetSelectedGroupValue(GroupDetails value) { this.SetField(ref _SelectedGroup, value, () => SelectedGroup); }