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()); }
public void Create(UserVsgroupViewModel model) { var result = mapper.Map <UserVsgroupViewModel, UserVsgroup>(model); userVsgroupRepository.Add(result); dbContext.Complete(); }