public UserController( SaveUser save, GetTolkenUser getTolkenUser) { _save = save; _getTolkenUser = getTolkenUser; }
public async Task <ActionResult> Save() { string input = null; using (StreamReader reader = new StreamReader(Request.Body, Encoding.UTF8)) { input = await reader.ReadToEndAsync(); } b2cUserModel inputClaims = b2cUserModel.Parse(input); string apiKey = "your-apikey"; string apiSecret = "your-apisecret"; string id = inputClaims.objectid; string tp = inputClaims.typingPattern; string quality = "2"; string base_url = string.Format("https://api.typingdna.com/save/{0}", id); var response = await saveUser(apiKey, apiSecret, base_url, tp); SaveUser saveUserResponse = SaveUser.FromJson(response); outputModel output = new outputModel(string.Empty, HttpStatusCode.OK) { status = saveUserResponse.Status }; return(Ok(output)); }
public BLResponse<User> SaveUser(SaveUser user, BLRequest blRequest){ Client.Execute(proxy=>{ if(user.Id==default(int)){ Rules.UserRules.ValidateOnSave(user, Users.Count(proxy)); Users.Post(proxy,user); } else{ Rules.UserRules.ValidateOnSave(user); Users.Put(proxy,user); } }); var r = new BLResponse<User>(); if(!IsCayita(blRequest)) r.Result.Add(user); else { var grid = BuildUserGrid(new List<User>()); var dr =grid.CreateRow(user); r.Html= dr.ToString(); } return r; }
public async Task <IActionResult> ExecuteAsync(SaveUser saveUser, CancellationToken cancellationToken) { var user = this.saveUserToUserMapper.Map(saveUser); user = await this.userRepository.AddAsync(user, cancellationToken).ConfigureAwait(false); var userViewModel = this.userToUserMapper.Map(user); return(new CreatedAtRouteResult( UsersControllerRoute.GetUser, new { userId = userViewModel.UserId }, userViewModel)); }
public async Task Seed() { _context.Database.EnsureCreated(); var user = await _userManager.FindByEmailAsync("*****@*****.**"); // Checking If user is not created if (user == null) { user = new SaveUser() { FirstName = "Chander", LastName = "Dhall", Email = "*****@*****.**", UserName = "******" }; var result = await _userManager.CreateAsync(user, "Password9!"); if (result != IdentityResult.Success) { throw new Exception("Unable to create user"); } } if (!_context.Movies.Any()) { // Insert new records var path = Path.Combine(_env.ContentRootPath, "Data/movies.json"); var content = File.ReadAllText(path); var movies = JsonConvert.DeserializeObject <IEnumerable <Movie> >(content); _context.Movies.AddRange(movies); var movieOrder = new MovieOrder() { OrderDateTime = DateTime.Now, OrderNumber = "123", User = user, Items = new List <MovieItem>() { new MovieItem() { Movie = movies.Last(), Quantity = 7, Price = movies.Last().Price } } }; _context.MovieOrders.Add(movieOrder); _context.SaveChanges(); } }
public async Task <ActionResult> Createuser([FromBody] SaveUser newUser) { var mappedUser = this.mapper.Map <SaveUser, User>(newUser); var result = await this.userService.CreateUser(mappedUser); if (result.Status == Ardalis.Result.ResultStatus.Ok) { return(Created($"users/{mappedUser.Id}", this.CreateUserResponse(result.Value))); } else { return(BadRequest(result.ValidationErrors)); } }
public async Task <IActionResult> ExecuteAsync(int userId, SaveUser saveUser, CancellationToken cancellationToken) { var user = await this.userRepository.GetAsync(userId, cancellationToken).ConfigureAwait(false); if (user is null) { return(new NotFoundResult()); } this.saveUserToUserMapper.Map(saveUser, user); user = await this.userRepository.UpdateAsync(user, cancellationToken).ConfigureAwait(false); var userViewModel = this.userToUserMapper.Map(user); return(new OkObjectResult(userViewModel)); }
public User Handle(SaveUser input) { var newUser = new User { FirstName = input.FirstName, LastName = input.LastName, Password = input.Password, Email = input.Email, CreatedAt = input.CreatedAt, Phones = input.Phones }; _context.Users.Add(newUser); _context.SaveChanges(); return(newUser); }
public JsonResult Signup([FromBody] SignupInput signupInput) { var listError = ValidateSignupInput(signupInput); if (listError.Any()) { return(Json(Utils.Utils.Instance.ResultMessage(string.Join(",", listError), false, 403))); } var hasEmail = _userService.Handle(new CheckHasEmail { Email = signupInput.Email }); if (hasEmail) { return(Json(Utils.Utils.Instance.ResultMessage("E-mail already exists", false, 403))); } var saveUser = new SaveUser { Email = signupInput.Email, CreatedAt = DateTime.Now, FirstName = signupInput.FirstName, LastName = signupInput.LastName, Password = signupInput.Password, Phones = signupInput.Phones.Select(s => new UserContact { CodeArea = s.AreaCode.Value, CountryCode = s.CountryCode, Number = s.Number.Value }).ToList() }; var newuser = _userService.Handle(saveUser); return(Json(Utils.Utils.Instance.ResultMessage($"User created successfully, userId:{newuser.Id}", true, 201))); }
public BLResponse<User> Post(SaveUser request) { return Controller.SaveUser(request,BLRequest); }
public BLResponse<User> Put(SaveUser request) { return Post(request); }
public async Task <ActionResult <SaveUserResult> > SaveAsync([FromBody] SaveUser model) { return(Ok(await _mediator.Send(model))); }
public async Task SaveUser(SaveUser user) { await _database.InsertOrReplaceAsync(user); }
public ActionResult EditUser(SaveUser saveUser) { return(Send(saveUser, x => RedirectToAction("Users"), () => EditUser(new GetUser { Id = saveUser.Id }))); }
public Task <IActionResult> PostAsync( [FromServices] IPostUserCommand command, [FromBody] SaveUser user, CancellationToken cancellationToken) => command.ExecuteAsync(user, cancellationToken);