public string OnNewUserInput(UserInputEventArgs e)
        {
            string temp = string.Empty;

            if (NewUserInput != null)
            {
                temp += NewUserInput.Invoke(e.FirstNumber, e.SecondNumber) + Environment.NewLine;
            }
            return(temp);
        }
 public ViewResult UserInfo(NewUserInput newUserInput)
 {
     if (ModelState.IsValid)
     {
         NewRepository.AddResponse(newUserInput);
         return(View("Thanks", newUserInput));
     }
     else
     {
         // there is a validation error
         return(View());
     }
 }
Ejemplo n.º 3
0
        public async Task <Payload <Guid> > NewUserAsync(
            NewUserInput input,
            [ScopedService] BookRefDbContext context)
        {
            if (context.Users.Any(e => e.Username.ToLower() == input.Username))
            {
                return(new Payload <Guid>(PayloadHelper.BuildSingleError(new Exception("Username already taken"))));
            }

            var user = new User(input.Username, input.Email);

            user.SetPassword(input.Password);
            await context.Users.AddAsync(user);

            var library = new PersonalLibrary(Guid.NewGuid(), user);
            await context.Libraries.AddAsync(library);

            await context.SaveChangesAsync();

            return(new Payload <Guid>(library.Id));
        }
Ejemplo n.º 4
0
 protected virtual void OnNewUserInput(Direction e)
 {
     NewUserInput?.Invoke(this, e);
 }