public void UsersDbAddUserReturnsTrue() { //Assign var usersDb = new UsersDb(); //Act + Assert Assert.IsTrue(usersDb.AddUser("", "")); }
private async void completeForm() { var model = new Book { Photo = "https://d1w7fb2mkkr3kw.cloudfront.net/assets/images/book/lrg/9781/1188/9781118881170.jpg", Edition = editionInput.Text, Title = titleInput.Text, Author = authorInput.Text, Posted = DateTime.Now, Faculty = facultySelection.SelectedItem.ToString(), CourseCode = courseCodeInput.Text, Price = float.Parse(priceInput.Text), Condition = conditionSelection.SelectedItem.ToString(), Description = descInput.Text.Trim(), Campus = campusSelection.SelectedItem.ToString() }; model.BooksImgs = JsonConvert.SerializeObject(imagePaths); //---------------------------------------------------------------------------// #region //Book book = new Book(); //book.Title = titleInput.Text.Trim(); //titleInput.Text = null; //book.Author = authorInput.Text.Trim(); //authorInput.Text = null; //book.Edition = editionInput.Text.Trim(); //editionInput.Text = null; //book.CourseCode = courseCodeInput.Text.Trim(); //courseCodeInput.Text = null; //book.Faculty = facultySelection.SelectedItem.ToString(); //facultySelection.SelectedIndex = 0; //book.Condition = conditionSelection.SelectedItem.ToString(); //conditionSelection.SelectedIndex = 0; //book.Description = descInput.Text.Trim(); //descInput.Text = null; //book.Price = float.Parse(priceInput.Text.Trim()); //priceInput.Text = null; //book.Campus = "City"; #endregion UsersDb.AddUser(new User()); BooksDb.AddBook(model); await DisplayAlert("Complate", "Your Book will post on the list soon", "OK"); Application.Current.MainPage = new HomePage(); await Shell.Current.GoToAsync("//main"); }
public void UsersDbGetUserReturnsIUser() { //Assign var usersDb = new UsersDb(); usersDb.AddUser("", ""); //Act + Assert Assert.IsTrue(usersDb.GetUser("", "") is IUser); }
public void OnSaveClicked(object sender, EventArgs args) { user = new Users(); usersDb = new UsersDb(); user.Username = txtUsername.Text; user.Email = txtEmail.Text; user.Password = txtPassword.Text; user.ConfirmPassword = txtConfirmPassword.Text; usersDb.AddUser(user); Navigation.PushAsync(new ManageUsers()); }
async void OnAuthCompleted(object sender, AuthenticatorCompletedEventArgs e) { var authenticator = sender as OAuth2Authenticator; if (authenticator != null) { authenticator.Completed -= OnAuthCompleted; authenticator.Error -= OnAuthError; } User user = null; if (e.IsAuthenticated) { //UserInfo = https://www.googleapis,com/oaurh2/v2/userinfo var request = new OAuth2Request("GET", new Uri(Constants.UserInfoUrl), null, e.Account); var response = await request.GetResponseAsync(); if (response != null) { string userJson = await response.GetResponseTextAsync(); user = JsonConvert.DeserializeObject <User>(userJson); } if (account != null) { store.Delete(account, Constants.AppName); } await store.SaveAsync(account = e.Account, Constants.AppName); await DisplayAlert("Name", User.Name, "OK"); await DisplayAlert("Email Address", User.Email, "OK"); try { UsersDb.AddUser(user); } catch (SqlException ex) { } App.CurrentUser = user; } Application.Current.MainPage = new HomePage(); await Shell.Current.GoToAsync("//main"); }
protected void submit_Click(object sender, EventArgs e) { Users _user = new Users(); _user.FirstName = fName.Value; _user.LastName = lName.Value; _user.EmailAddress = email.Value; _user.Password = pwd.Value; _user.Birthday = DateTime.Parse(dob.Value); if (!DoesUserExist(_user.EmailAddress)) { UsersDb _usersDb = new UsersDb(); if (pwd.Value == cpwd.Value) { int userId = _usersDb.AddUser(_user); Random rnd = new Random(); decimal _balance = rnd.Next(100, 1000000); Accounts _account = new Accounts(); _account.AccountNumber = Convert.ToInt32(accountNum.Value.ToString()); _account.AccountType = accounttype.Value; _account.Fk_UserId = userId; _account.Balance = _balance; AccountDb _accountDb = new AccountDb(); int account = _accountDb.AddAccount(_account); _user.Id = userId; Session["LoggedIn"] = _user.Id.ToString(); Response.Redirect("/Index.aspx"); } else { this.error.Visible = true; this.error.InnerText = "Password and Confirm Password must match."; } } else { this.error.Visible = true; this.error.InnerText = "Email Address is already in use."; } }