예제 #1
0
        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;
        }
예제 #2
0
        public DetailUserViewModel()
        {
            User = new User();

            // TEMP DATA
            User.RealName = "Kristofer Selbekk";
            User.UserName = "******";
            User.Email = "*****@*****.**";
            User.PhoneNumber = "92673134";
            User.AccessLevel = PermissionLevel.AdminOnly;
        }
예제 #3
0
 public void SaveUser(User user)
 {
     ctrl.RegisterUser(user);
 }
예제 #4
0
        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;
                }
            }
        }