public async Task <ActionResult> Register(BeSafeModels.User user) { if (ModelState.IsValid) { BeSafeEntities.User LogedinUser = UserBusinessLogic.UserValidation(user.UserName, user.Password).Result; if (LogedinUser == null) { var userEntity = mapUserModelToEntity.ConvertObject(user); userEntity.CreatedDate = DateTime.Now; LogedinUser = await UserBusinessLogic.AddUser(userEntity); } var claims = new List <Claim> { new Claim(ClaimTypes.Name, LogedinUser.UserName), new Claim(ClaimTypes.Sid, LogedinUser.ID.ToString()), new Claim(ClaimTypes.Email, LogedinUser.Email) }; var claimsIdentity = new ClaimsIdentity(claims, "Login"); await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(claimsIdentity)); return(RedirectToAction("Index", "Admin")); } return(View(user)); }
public ActionResult CreateUser([FromBody] User data) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { userBusinessLogic.AddUser(data); return(Ok(mapper.Map <UserDTO>(data))); } catch (UserException e) { return(BadRequest(e.Message)); } catch (Exception e) { return(StatusCode(500, e.Message)); } }
public void AddUserOkTest() { mockUserRepo.Setup(x => x.Insert(It.IsAny <User>())).Callback <User>(x => userList.Add(userWithAllData)); userBLWithoutTeamBL.AddUser(userWithAllData); mockUserRepo.Verify(x => x.Insert(It.IsAny <User>()), Times.Once()); }
public void AddUser_ExpectedParameters_Ok() { userBusinessLogic.AddUser(user); }