public DetailStoryViewModel() { //temp drit UserStory = new Story(); UserStory.Description = "Random description. blablablablablablabla. blablalbllalblalbal"; UserStory.Title = "Random Title"; User tempUser = new User(); tempUser.UserName = "******"; tempUser.RealName = "Hans Petter Naumann"; UserStory.Author = tempUser; UserStory.CreatedDate = DateTime.Now; Comment c1 = new Comment(); c1.Author = tempUser; c1.Text = "random comment. blabla"; c1.TimeStamp = DateTime.Now; Comment c2 = new Comment(); c2.Author = tempUser; c2.Text = "random comment number 2. blabla"; c2.TimeStamp = DateTime.Now; UserStory.Comments.Add(c1); UserStory.Comments.Add(c2); UserStory.Assignee = tempUser; }
public DetailUserViewModel() { User = new User(); // TEMP DATA User.RealName = "Kristofer Selbekk"; User.UserName = "******"; User.Email = "*****@*****.**"; User.PhoneNumber = "92673134"; User.AccessLevel = PermissionLevel.AdminOnly; }
public void SaveUser(User user) { ctrl.RegisterUser(user); }
private bool SaveUser() { if (!IsValid()) { setError(App.Current.Resources["errRequiredFieldsEmpty"] as String); return false; } // Checks for valid email if (!IsValidEmailAddress(txtEmail.Text)) { setError(App.Current.Resources["errMisformedEmail"] as String); return false; } // Creates a User-object User user = new User() { RealName = txtRealName.Text, UserName = txtUserName.Text, Email = txtEmail.Text, Password = txtPassword.Password, PhoneNumber = txtPhone.Text, AccessLevel = ((PermissionBox.SelectedItem as String) == "Administrator" ? PermissionLevel.AdminOnly : PermissionLevel.UserOnly) }; // Tries to register the user try { vm.SaveUser(user); return true; } catch (ArgumentException ex) { if (ex.Message == "Username taken") { setError("The username is already taken."); return false; } else // User object is not valid. { setError(App.Current.Resources["errGeneralError"] as String); return false; } } }