예제 #1
0
 public void Delete()
 {
     Contacts.Remove(this.Sms.Name);
 }
예제 #2
0
        void HandleDoneClicked(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(nameElement.Value))
            {
                UIAlertView alert = new UIAlertView(
                    Settings.GetLocalizedString("Group Name Error", LocalizedKey),
                    Settings.GetLocalizedString("You must specify a group name", LocalizedKey), null, "OK");
                alert.Show();
                return;
            }

            // 3 cases :
            // 1. New Group = check that the group does not exist, prompt if exist
            // 2. Editing = Update everything..
            // 3. Edit group result in overriding existing group
            if (!isEditing)
            {
                if (Contacts.GetAll().Any(x => x.Name.ToLower().Equals(nameElement.Value.ToLower())))
                {
                    UIAlertView alert = new UIAlertView(
                        Settings.GetLocalizedString("Group Name Error", LocalizedKey),
                        Settings.GetLocalizedString("Can't create the group because a group with the same name exists", LocalizedKey),
                        null, "OK");
                    alert.Show();
                    return;
                }
            }
            else
            {
                if (this.smsGroup.Sms.Name.ToLower() != nameElement.Value.ToLower() && Contacts.GetAll().Any(x => x.Name.ToLower().Equals(nameElement.Value.ToLower())))
                {
                    UIAlertView alert = new UIAlertView(
                        Settings.GetLocalizedString("Group Name Error", LocalizedKey),
                        Settings.GetLocalizedString("Can't update the group because a group with the same name exists", LocalizedKey),
                        null, "OK");
                    alert.Show();
                    return;
                }
            }

            SaveGroup();
            ReturnToMainScreen();
        }