//public NOTE NOTE { get; set; } public User(CUSTOMER c) { Constants.UserEntity = c; //ctx = new CloudEDUEntities(new Uri(Constants.DataServiceURI)); NAME = c.NAME; ID = c.ID; EMAIL = c.EMAIL; PASSWORD = c.PASSWORD; TEACH_RATE = c.TEACH_RATE; LEARN_RATE = c.LEARN_RATE; DEGREE = c.DEGREE; BIRTHDAY = c.BIRTHDAY; BALANCE = c.BALANCE; ALLOW = c.ALLOW; //!!!!!!! SetAttendTeachNumber(); //TaskFactory<IEnumerable<CUSTOMER>> tf = new TaskFactory<IEnumerable<CUSTOMER>>(); //customerDsq = (DataServiceQuery<CUSTOMER>)(from user in ctx.CUSTOMER where user.NAME.Equals(InputUsername.Text) select user); //IEnumerable<CUSTOMER> cs = await tf.FromAsync(customerDsq.BeginExecute(null, null), iar => customerDsq.EndExecute(iar)); //csl = new List<CUSTOMER>(cs); Constants.Save<string>("LastUser", NAME); ImageSource = (c.EMAIL!=null)?"http://www.gravatar.com/avatar/" + Constants.ComputeMD5(c.EMAIL)+"?s=400":""; CreateDBAndInsert(); }
/// <summary> /// Handles the Click event of the Button control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param> private async void Button_Click(object sender, RoutedEventArgs e) { if (InputUsername.Text.Equals(string.Empty) || InputPassword.Password.Equals(string.Empty)) { var messageDialog = new MessageDialog("Check your input!"); await messageDialog.ShowAsync(); return; } if (!Constants.isUserNameAvailable(InputUsername.Text)) { var messageDialog = new MessageDialog("Check your input! Username can only contain 1-9 a-z and _"); await messageDialog.ShowAsync(); return; } if (!InputPassword.Password.Equals(ReInputPassword.Password)) { var dialog = new MessageDialog("Passwords are not same! Try again, thx!"); await dialog.ShowAsync(); return; } if (isUserAlreadyThere()) { var dialog = new MessageDialog("Username already exists"); await dialog.ShowAsync(); return; } //CUSTOMER c = CUSTOMER.CreateCUSTOMER(null, InputUsername.Text, InputPassword.Password, null, null, null); c = new CUSTOMER() { NAME = InputUsername.Text, PASSWORD = Constants.ComputeMD5(InputPassword.Password), ALLOW = true, BALANCE = 100, }; ctx.AddToCUSTOMER(c); ctx.BeginSaveChanges(OnCustomerSaveChange, null); }
/// <summary> /// Handles the Tapped event of the SaveImage control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="TappedRoutedEventArgs"/> instance containing the event data.</param> private async void SaveImage_Tapped(object sender, TappedRoutedEventArgs e) { if (passwordBox.Password.Equals(string.Empty) || retypePasswordBox.Password.Equals(string.Empty)) { var messageDialog = new MessageDialog("Please Check your input, Password can't be empty!"); await messageDialog.ShowAsync(); return; } if (!Constants.isEmailAvailable(email.Text)) { var messageDialog = new MessageDialog("Please Check your input, EMAIL is not Available!"); await messageDialog.ShowAsync(); return; } if (!passwordBox.Password.Equals(retypePasswordBox.Password)) { var dialog = new MessageDialog("Passwords are not same! Try again, thx!"); await dialog.ShowAsync(); return; } foreach (CUSTOMER c in csl) { if (c.NAME == Constants.User.NAME) { c.DEGREE = (string)degreeBox.SelectedItem; c.PASSWORD = Constants.ComputeMD5(passwordBox.Password); c.EMAIL = email.Text; c.BIRTHDAY = Convert.ToDateTime(birthday.Text); changedCustomer = c; ctx.UpdateObject(c); ctx.BeginSaveChanges(OnCustomerSaveChange, null); } } }