示例#1
0
        public async Task <IActionResult> AddUserInGroup(string userName, string groupId)
        {
            var user = await userManager.FindByNameAsync(userName);

            if (user != null)
            {
                var userVsGroup = userVsgroupService.GetByUserNameAndGroupId <UserVsgroupViewModel>(userName, groupId);

                if (userVsGroup == null)
                {
                    var model = new UserVsgroupViewModel()
                    {
                        Id      = Guid.NewGuid().ToString(),
                        GroupId = groupId,
                        UserId  = user.Id,
                    };

                    userVsgroupService.Create(model);

                    return(Ok());
                }

                return(BadRequest());
            }

            return(BadRequest());
        }