예제 #1
0
        void btnOK_Click(object sender, RoutedEventArgs e)
        {
            int?groupID = null;

            if (IsExistingGroup)
            {
                if (lbGroups.SelectedItem == null)
                {
                    MessageBox.Show(Shoko.Commons.Properties.Resources.MSG_ERR_GroupSelectionRequired, Shoko.Commons.Properties.Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);
                    lbGroups.Focus();
                    return;
                }
                else
                {
                    SelectedGroup = lbGroups.SelectedItem as VM_AnimeGroup_User;
                    DialogResult  = true;
                    Close();
                }
            }

            if (IsNewGroup)
            {
                if (txtGroupName.Text.Trim().Length == 0)
                {
                    MessageBox.Show(Shoko.Commons.Properties.Resources.MSG_ERR_GroupNameRequired, Shoko.Commons.Properties.Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);
                    txtGroupName.Focus();
                    return;
                }

                VM_AnimeGroup_User grp = new VM_AnimeGroup_User();
                grp.GroupName           = txtGroupName.Text.Trim();
                grp.SortName            = txtGroupName.Text.Trim();
                grp.AnimeGroupParentID  = null;
                grp.Description         = "";
                grp.IsFave              = 0;
                grp.IsManuallyNamed     = 0;
                grp.OverrideDescription = 0;


                if (grp.Validate())
                {
                    grp.IsReadOnly    = true;
                    grp.IsBeingEdited = false;
                    if (grp.Save())
                    {
                        VM_MainListHelper.Instance.ViewGroups.Refresh();
                        groupID = grp.AnimeGroupID;
                    }
                }
                SelectedGroup = grp;
                DialogResult  = true;
                Close();
            }
        }
예제 #2
0
        void btnConfirm_Click(object sender, RoutedEventArgs e)
        {
            //VM_AnimeGroup_User grp = null;
            int animeID = 0;
            int?groupID = null;

            try
            {
                if (IsAnimeNotSelected)
                {
                    MessageBox.Show(Shoko.Commons.Properties.Resources.NewSeries_SelectAnime, Shoko.Commons.Properties.Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);
                    txtAnimeSearch.Focus();
                    return;
                }

                if (IsExistingGroup)
                {
                    if (lbGroups.SelectedItem == null)
                    {
                        MessageBox.Show(Shoko.Commons.Properties.Resources.MSG_ERR_GroupSelectionRequired, Shoko.Commons.Properties.Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);
                        lbGroups.Focus();
                        return;
                    }
                    else
                    {
                        VM_AnimeGroup_User grp = lbGroups.SelectedItem as VM_AnimeGroup_User;
                        groupID = grp.AnimeGroupID;
                    }
                }

                if (IsNewGroup)
                {
                    if (txtGroupName.Text.Trim().Length == 0)
                    {
                        MessageBox.Show(Shoko.Commons.Properties.Resources.MSG_ERR_GroupNameRequired, Shoko.Commons.Properties.Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);
                        txtGroupName.Focus();
                        return;
                    }
                }

                if (SelectedAnime != null)
                {
                    animeID = SelectedAnime.AnimeID;
                }

                Cursor = Cursors.Wait;

                if (IsNewGroup)
                {
                    VM_AnimeGroup_User grp = new VM_AnimeGroup_User();
                    grp.GroupName           = txtGroupName.Text.Trim();
                    grp.SortName            = txtGroupName.Text.Trim();
                    grp.AnimeGroupParentID  = null;
                    grp.Description         = "";
                    grp.IsFave              = 0;
                    grp.IsManuallyNamed     = 0;
                    grp.OverrideDescription = 0;


                    if (grp.Validate())
                    {
                        grp.IsReadOnly    = true;
                        grp.IsBeingEdited = false;
                        if (grp.Save())
                        {
                            VM_MainListHelper.Instance.ViewGroups.Refresh();
                            groupID = grp.AnimeGroupID;
                        }
                    }
                }


                CL_Response <CL_AnimeSeries_User> response = VM_ShokoServer.Instance.ShokoServices.CreateSeriesFromAnime(animeID, groupID,
                                                                                                                         VM_ShokoServer.Instance.CurrentUser.JMMUserID);
                if (response.ErrorMessage.Length > 0)
                {
                    Cursor = Cursors.Arrow;
                    MessageBox.Show(response.ErrorMessage, Shoko.Commons.Properties.Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }

                VM_MainListHelper.Instance.AllSeriesDictionary[response.Result.AnimeSeriesID] = (VM_AnimeSeries_User)response.Result;
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
            finally
            {
                Cursor = Cursors.Arrow;
            }

            DialogResult = true;
            Close();
        }