예제 #1
0
        private void UserCompleted(object sender, EventArgs e)
        {
            string name = NameEntry.Text;
            string bio  = BioEntry.Text;

            if (name == null || name == "")
            {
                NameEntry.TextColor = Color.Accent;
            }
            else if (_purpose == EditPurpose.createNew && _localData.GetUsers().Any(u => u.Name == name))
            {
                NameEntry.TextColor = Color.Accent;
            }
            else if (bio == null || bio == "")
            {
                NameEntry.TextColor = Color.DarkCyan;
                BioEntry.TextColor  = Color.Accent;
            }
            else
            {
                NameEntry.TextColor = Color.DarkCyan;
                BioEntry.TextColor  = Color.DarkCyan;

                User user = new User(0, link, name, bio);

                if (_purpose == EditPurpose.createNew)
                {
                    _localData.AddNewUser(user);
                    user.Id = _localData.GetUsers().Find(u => u.Name == user.Name).Id;
                }
                else if (_purpose == EditPurpose.update)
                {
                    _localData.UpdateUser(oldUser, user);
                    user = _localData.GetUsers().Find(u => u.Id == oldUser.Id);
                }
                else
                {
                    throw new NotImplementedException();
                }

                EditorResult();
            }
        }