Пример #1
0
        public Result <GroupUserViewModel> GetGroupUserViewModel(string groupId)
        {
            _logger.LogInformation($"Getting Group. GroupId {groupId}");

            SelectSpecification <GroupEntity, GroupUserViewModel> selectSpecification = new SelectSpecification <GroupEntity, GroupUserViewModel>();

            selectSpecification.AddFilter(x => x.Id == groupId);
            selectSpecification.AddSelect(x => new GroupUserViewModel(
                                              x.Id,
                                              x.Name));

            GroupUserViewModel groupUserViewModel = _groupStore.Get(selectSpecification);

            if (groupUserViewModel == null)
            {
                _logger.LogError($"No Group. GroupId {groupId}");
                return(Result.Fail <GroupUserViewModel>("no_group", "No Group"));
            }

            groupUserViewModel.CanAssigneGroupRoles = _groupUserStore.CanAssigneGroupRoles();
            groupUserViewModel.CanMangeGroupRoles   = _groupUserStore.CanManageGroupRoles();
            groupUserViewModel.CanChangeOwnRole     = _groupUserStore.CanChangeOwnRole();

            return(Result.Ok(groupUserViewModel));
        }
        // GET: UserGroup

        public ActionResult GroupUser()
        {
            var model = new GroupUserViewModel
            {
                UserGroups = groupRepository.GetAll()
            };

            return(View(model));
        }
        public async Task <IViewComponentResult> InvokeAsync(int groupId, string userId)
        {
            GroupUserViewModel groupUserInfo = new GroupUserViewModel();

            if (ValidationsOK(groupId, userId))
            {
                groupUserInfo.IsUserSignedIn = true;
                groupUserInfo.GroupId        = groupId;
                groupUserInfo.UserId         = userId;
                if (await IsUserMemberOfGroupAsync())
                {
                    groupUserInfo.IsUserMember        = true;
                    groupUserInfo.GroupMemberProfiles = await GetUserProfilesInThisGroupAsync();
                }
            }
            return(View(groupUserInfo));
        }
Пример #4
0
        public virtual ActionResult ManageUser(Guid groupUserId)
        {
            // Get the Group
            var groupUser  = _groupService.GetGroupUser(groupUserId);
            var roles      = _roleService.AllRoles().Where(x => x.RoleName != Constants.GuestRoleName);
            var selectList = new List <SelectListItem>(roles.Select(x => new SelectListItem {
                Text = x.RoleName, Value = x.Id.ToString()
            }));

            var viewModel = new GroupUserViewModel
            {
                GroupUser       = groupUser,
                GroupUserStatus = groupUser.GetUserStatusForGroup(),
                RoleSelectList  = selectList,
                MemberRole      = GetGroupMembershipRole(groupUser.Group.Id)
            };

            return(View(viewModel));
        }
Пример #5
0
        public virtual async Task <ActionResult> ManageUserAsync(GroupUserViewModel model, CancellationToken cancellationToken = default(CancellationToken))
        {
            // Get the Group
            var groupUser = await _groupService.UpdateGroupUserAsync(model.GroupUser, cancellationToken);

            var roles      = _roleService.AllRoles();
            var selectList = new List <SelectListItem>(roles.Select(x => new SelectListItem {
                Text = x.RoleName, Value = x.Id.ToString()
            }));

            var viewModel = new GroupUserViewModel
            {
                GroupUser       = groupUser,
                GroupUserStatus = groupUser.GetUserStatusForGroup(),
                RoleSelectList  = selectList,
                MemberRole      = GetGroupMembershipRole(groupUser.Group.Id)
            };

            return(View(viewModel));
        }
Пример #6
0
 public IActionResult AddUsers([Bind] GroupUserViewModel item)
 {
     if (ModelState.IsValid)
     {
         var userId    = this.User.FindFirstValue(ClaimTypes.NameIdentifier);
         var userThis  = userManager.Users.FirstOrDefault(u => u.Id == userId);
         var groupId   = userThis.ApplicationGroupId;
         var groupName = groupManager.Get(groupId).Name;
         var user      = userManager.Users.FirstOrDefault(u => u.Email == item.Email);
         if (user == null)
         {
             string subjectNew = "Invite to SMS Service registration";
             var    sb         = new StringBuilder("You invited to SMS Servise Application by ");
             sb.AppendFormat("{0} company. If you know this company - please ", groupName);
             string dom = "http://localhost:53759";
             sb.AppendFormat("<a href='{0}/Account/NewRegister?groupId={1}'> click here to registration </a>", dom, groupId);
             string messageNew = sb.ToString();
             emailSender.SendEmailAsync(item.Email, subjectNew, messageNew);
         }
         else
         {
             user.InviteId = groupId;
             notificationManager.AddNotificationsToUser((new PersonalNotificationBuilder(user))
                                                        .SetMessage("Group invite", "You have been invited to group " + groupName)
                                                        .SetTime(DateTime.Now)
                                                        .GenerateHref(Url, "Manage", "Index")
                                                        .Build());
             userManager.UpdateAsync(user);
             string subjectNew = "SMS Service invite you to join the group";
             var    sb         = new StringBuilder("You invited to join the group ");
             sb.AppendFormat("{0}. If you accept this - please ", groupName);
             string dom = "http://localhost:53759";
             sb.AppendFormat("<a href='{0}/Manage/Index'> click here to join </a>", dom);
             string messageNew = sb.ToString();
             emailSender.SendEmailAsync(item.Email, subjectNew, messageNew);
         }
         return(RedirectToAction("Index"));
     }
     return(View(item));
 }
        public ActionResult Index(int?Id)
        {
            if (Id == null)
            {
                return(RedirectToAction("BadRequestError", "ErrorController"));
            }

            var Group = _context.Groups.Find(Id);

            if (Group == null)
            {
                return(RedirectToAction("HttpNotFoundError", "ErrorController"));
            }

            Session["GroupId"] = Id;

            //***
            IEnumerable <string> UsersGroupFound = _context.UsersGroups.Where(a => a.GroupId == Id).Select(a => a.UserId);



            var Users      = _context.Users.Where(a => (!UsersGroupFound.Contains(a.Id) && !a.RoleName.Equals("Master")));
            var GroupUsers = new List <GroupUserViewModel>();

            foreach (var item in Users)
            {
                var viewModel = new GroupUserViewModel
                {
                    GroupId  = Id.Value,
                    UserName = item.UserName,
                    UserId   = item.Id,
                    FullName = item.FullName
                };
                GroupUsers.Add(viewModel);
            }

            return(View(GroupUsers));
        }