Exemplo n.º 1
0
        public PagedResponse <GenreDto> Execute(GenreSearch search)
        {
            var query = _context.Genres.AsQueryable();

            if (!string.IsNullOrEmpty(search.Name) || !string.IsNullOrWhiteSpace(search.Name))
            {
                query = query.Where(x => x.Name.ToLower().Contains(search.Name.ToLower()));
            }
            var skipCount = search.PerPage * (search.Page - 1);

            //var response = _mapper.Map<PagedResponse<GenreDto>>(query);

            var response = new PagedResponse <GenreDto>
            {
                TotalCount   = query.Count(),
                CurrentPage  = search.Page,
                ItemsPerPage = search.PerPage,
                Items        = query.Skip(skipCount)
                               .Take(search.PerPage)
                               .Select(x => new GenreDto
                {
                    Id   = x.Id,
                    Name = x.Name
                }).ToList()
            };

            return(response);
        }
Exemplo n.º 2
0
        public IEnumerable <GenreDto> Execute(GenreSearch request)
        {
            var query = Context.Genres.AsQueryable();

            if (request.Name != null)
            {
                query = query.Where(g => g.Name.ToLower().Trim().Contains(request.Name.ToLower()));
            }

            if (request.IsDeleted.HasValue)
            {
                query = query.Where(p => p.IsDeleted == request.IsDeleted);
            }
            else
            {
                query = query.Where(p => p.IsDeleted == false);
            }

            var TotalRecords = query.Count();

            if (request.page.HasValue && request.PageSize.HasValue)
            {
                query = query.Skip((request.page ?? 0 - 1) * request.PageSize ?? 0).Take(request.PageSize ?? 0);
            }

            return(query.Select(g => new GenreDto
            {
                Id = g.Id,
                Name = g.Name,
                CreatedAt = g.CreatedAt,
                TotalRecords = TotalRecords
            }));
        }
Exemplo n.º 3
0
        public async Task GetAnimeGenre_InvalidGenre_ShouldThrowValidationException(GenreSearch genreSearch)
        {
            // When
            Func <Task <AnimeGenre> > func = this._jikan.Awaiting(x => x.GetAnimeGenre(genreSearch));

            // Then
            await func.Should().ThrowExactlyAsync <JikanValidationException>();
        }
Exemplo n.º 4
0
 public string genre(GenreSearch genre)
 {
     try
     {
         result = orm.execObject <Result>(genre, "api.admin_genre_search");
     }
     catch (Exception exp)
     {
         errorResult(exp);
     }
     return(formattedResult(result));
 }
Exemplo n.º 5
0
 public ActionResult <IEnumerable <GenreDto> > Get([FromQuery] GenreSearch obj)
 {
     try
     {
         var data = _getGenres.Execute(obj);
         return(Ok(data));
     }
     catch
     {
         return(StatusCode(500, "Internal Server Error!"));
     }
 }
Exemplo n.º 6
0
        public CatalogueViewModel(GenreSearch genreEnum)
        {
            _currentGenre = genreEnum;

            // se eu tenho um gênero singular selecionado(cheguei aqui clicando em um único gênero específico de um anime em AnimesSpecs)
            HasSelectedGenre = true;

            ClearTextQuery();

            InitializeDefaultProperties();

            InitializeTask = LoadAsync(null);
        }
Exemplo n.º 7
0
        public async Task OnGenreSearch(string genreName)
        {
            if (IsNotBusy)
            {
                IsBusy = true;
                string      formatedString = genreName.RemoveOcurrencesFromString(new char[] { '-', ' ' });
                GenreSearch genre          = (GenreSearch)Enum.Parse(typeof(GenreSearch), formatedString, true);

                await NavigationManager.NavigateShellAsync <CatalogueViewModel>(genre);

                IsBusy = false;
            }
        }
Exemplo n.º 8
0
        public static string GetGenre(string defaultGenre)
        {
            GenreSearch s = new GenreSearch(GenreSearch.Fields.Name);

            Inputbox ib = new Inputbox("Choose a genre: ", s.PerformSearchToScalar().ToArray(),
                                       defaultGenre, false);

            if (ib.ShowDialog() == DialogResult.Cancel)
            {
                return(null);
            }
            else
            {
                return(ib.SelectedItem.ToString());
            }
        }
Exemplo n.º 9
0
 public IActionResult Get([FromQuery] GenreSearch search,
                          [FromServices] IGetGenresQuery query)
 {
     return(Ok(_executor.ExecuteQuery(query, search)));
 }
Exemplo n.º 10
0
        public async Task GetMangaGenre_InvalidGenreValidPage_ShouldThrowValidationException(GenreSearch genreSearch)
        {
            // When
            Func <Task <MangaGenre> > func = _jikan.Awaiting(x => x.GetMangaGenre(genreSearch, 1));

            // Then
            await func.Should().ThrowExactlyAsync <JikanValidationException>();
        }
Exemplo n.º 11
0
 public GenreData(GenreSearch genre)
 {
     Genre = genre;
 }
Exemplo n.º 12
0
        public Browse()
        {
            InitializeComponent();

            status_reset_timer          = new Timer();
            status_reset_timer.Interval = 6000; // reset status message to "Ready" after 6 sec
            status_reset_timer.Tick    += (sender, e) =>
            {
                this.change_status("Ready", false);
                status_reset_timer.Enabled = false;
            };

            if (System.ComponentModel.LicenseManager.UsageMode ==
                System.ComponentModel.LicenseUsageMode.Runtime)
            {
                artistSearch = new ArtistSearch(ArtistSearch.Fields.ID,
                                                ArtistSearch.Fields.FullName,
                                                ArtistSearch.Fields.MatchName);
                artistSearch.AddTypeToSearch(ArtistSearch.TypeCategory.Composers);

                genreSearch = new GenreSearch(GenreSearch.Fields.ID, GenreSearch.Fields.Name);

                pieceSearch = new PieceSearch(PieceSearch.Fields.ID, PieceSearch.Fields.Name,
                                              PieceSearch.Fields.ParentPieceID);

                SupressUpdate = false;

                UpdateArtistList();
                UpdateGenreList();
                UpdatePieceList(false);
            }

            txbComposer.Focus();

            // hide the tabs of tabControlMode
            Rectangle rect = new Rectangle(tabPageSearch.Left, tabPageSearch.Top, tabPageSearch.Width, tabPageSearch.Height);

            tabControlMode.Region = new Region(rect);

            txbComposer.SetDefaultText(TextBoxDefaultAll);
            txbComposer.PopupWidth    = -1;
            txbComposer.ItemSelected += (sender, e) =>
            {
                UpdateGenreList();
                UpdatePieceList(false);

                if (txbComposer.SelectedItem != null)
                {
                    txbFilter.Focus();
                }
            };
            txbComposer.TextChanged += (sender, e) =>
            {
                SupressUpdate = true;
                txbGenre.ResetText();
                txbFilter.Text = TextBoxDefaultNone;
                SupressUpdate  = false;
            };
            txbComposer.KeyDown += (sender, e) =>
            {
                if (e.KeyData == Keys.Enter)
                {
                    if (txbComposer.SelectedItem != null || !txbComposer.HasText())
                    {
                        txbFilter.Focus();
                    }
                    else
                    {
                        if (AddNewComposer(txbComposer.Text)) // add new composer and set focus to dg if add is successful
                        {
                            dg.Focus();
                        }
                    }
                }
                else if (e.KeyData == Keys.F2 && txbComposer.HighlightedItem != null)
                {
                    //change_status(txbComposer.HighlightedValue.ToString() + txbComposer.HighlightedItem.ToString());
                    int id = int.Parse(txbComposer.HighlightedValue.ToString());
                    txbComposer.HideAutoCompleteList();
                    RenameComposer(id, "");
                }
                else if (e.KeyData == Keys.Delete && txbComposer.HighlightedItem != null)
                {
                    int id = int.Parse(txbComposer.HighlightedValue.ToString());
                    txbComposer.HideAutoCompleteList();
                    DeleteComposer(id);
                }
                else
                {
                    return;
                }

                e.Handled = true;
            };
            //txbComposer.LostFocus += new EventHandler(txb_LostFocus);

            txbGenre.SetDefaultText(TextBoxDefaultAll);
            txbGenre.PopupWidth = -1;
            //txbGenre.LostFocus += txb_LostFocus;
            txbGenre.ItemSelected += (sender, e) => UpdatePieceList(false);

            txbFilter.Text         = TextBoxDefaultNone;
            txbFilter.TextChanged += (sender, e) => UpdatePieceList(false);
            txbFilter.KeyDown     += txb_KeyDown;
            txbFilter.KeyDown     += (sender, e) =>
            {
                if (e.KeyData == Keys.Down)
                {
                    dg.Focus();
                }
            };
            txbFilter.Enter += (sender, e) => txbFilter.SelectAll();

            dg.Rows.Clear();
            dg.CellFormatting += (sender, e) =>
            {
                // highlight the fact that the control is not in focus
                e.CellStyle.SelectionBackColor = ((DataGridView)sender).Focused ?
                                                 SystemColors.Highlight : SystemColors.InactiveCaption;

                // highlight the pieces that are "derived" from other pieces (i.e. a transcription, etc.)
                e.CellStyle.ForeColor = (dg[2, e.RowIndex].Value == null) ?
                                        SystemColors.ControlText : Color.Gray;

                // highlight the cell in edit mode
                if (dg.IsCurrentCellInEditMode && dg.CurrentCell == dg[e.ColumnIndex, e.RowIndex])
                {
                    e.CellStyle.BackColor = CellInEditColor;
                }
            };
            dg.SortCompare += (sender, e) =>
            {
                // use natural sorting
                if (dg[1, e.RowIndex1].Value == null || dg[1, e.RowIndex2].Value == null)
                {
                    return;
                }
                e.SortResult = NaturalSortComparer.Default.Compare(dg[1, e.RowIndex1].Value.ToString(),
                                                                   dg[1, e.RowIndex2].Value.ToString());
                e.Handled = true;
            };
            dg.KeyDown += (sender, e) =>
            {
                if (e.KeyData == Keys.Up || e.KeyData == Keys.Down)
                {
                    IsScrolling = true; // don't fetch data if the user is scrolling fast
                }
                else if (e.KeyCode == Keys.Enter)
                {
                    e.Handled = true;

                    // move to next control
                    if (e.Shift)
                    {
                        tabControl.SelectedTab = tabControl.TabPages[2];
                        tabControl.Focus();
                    }
                    else
                    {
                        if (clbDetail.Items.Count != 0)
                        {
                            clbDetail.SelectedIndex = 0;
                        }
                        if (tabControl.SelectedTab == tabControl.TabPages[0] && clbDetail.Items.Count == 0)
                        {
                            tabControl.SelectedTab = tabControl.TabPages[1]; // goto text edit mode
                        }
                        tabControl.Focus();
                    }
                }
                else if (e.KeyData == Keys.Escape)
                {
                    txbFilter.Focus();
                }
                else if (e.KeyData == (Keys.Home))
                {
                    dg.ClearSelection();
                    dg.CurrentCell          = dg[1, 0];
                    dg.CurrentCell.Selected = true;
                }
                else if (e.KeyData == (Keys.End))
                {
                    dg.ClearSelection();
                    dg.CurrentCell          = dg[1, dg.RowCount - 1];
                    dg.CurrentCell.Selected = true;
                }
            };
            dg.KeyUp += (sender, e) =>
            {
                if (e.KeyData == Keys.Up || e.KeyData == Keys.Down)
                {
                    // resume fetchting data after user stop fast scrolling
                    IsScrolling = false;

                    //force re-selection so that the SelectionChanged event will fire
                    dg.ClearSelection();
                    dg.Rows[dg.CurrentRow.Index].Selected = true;
                }
                else if (e.KeyData == (Keys.Alt | Keys.P))
                {
                    tabControl.SelectedTab = tabControl.TabPages[2];
                    dg.Focus();
                }
                else if (e.KeyData == (Keys.Alt | Keys.M))
                {
                    tabControl.SelectedTab = tabControl.TabPages[0];
                    dg.Focus();
                }
                else if (e.KeyData == (Keys.Control | Keys.E))
                {
                    //start text edit mode
                    tabControl.SelectedTab = tabControl.TabPages[1];
                    tabControl.Focus();
                }
                else if (e.KeyData == Keys.Delete)
                {
                    DeletePiece();
                }
            };
            dg.SelectionChanged += (sender, e) => { if (!IsScrolling)
                                                    {
                                                        UpdateDetail();
                                                    }
            };
            dg.GotFocus += (sender, e) =>
            {
                if (dg.SelectedRows.Count == 0) //auto select first row if nothing is already selected
                {
                    dg.Rows[0].Selected = true;
                }
            };
            dg.CellEndEdit += (sender, e) =>
            {
                dg.CurrentCell = dg[e.ColumnIndex, e.RowIndex];
                if (dg[0, e.RowIndex].Value == null && dg.CurrentCell.Value != null)
                {
                    if (!AddNewPiece(dg.CurrentCell.Value.ToString()))
                    {
                        dg.Rows.Remove(dg.Rows[dg.CurrentCell.RowIndex]);
                    }
                }
                else if (!dg.CurrentRow.IsNewRow)
                {
                    RenamePiece(dg.CurrentCell.Value.ToString());
                }
            };

            clbDetail.KeyDown              += new KeyEventHandler(clbDetail_KeyDown);
            clbDetail.LostFocus            += (sender, e) => clbDetail.ClearSelected();
            clbDetail.SelectedIndexChanged += (sender, e) =>
            {
                // show preview of how the formatted name is like on statusbar
                if (!DetailPaneVisible)
                {
                    return;                     // no need to update UI
                }
                if (clbDetail.SelectedIndex != -1 && currentPiece != null)
                {
                    change_status(currentPiece.FormatDetail(clbDetail.SelectedItem.ToString()));
                }
            };

            // don't focus on the tabs themselves
            tabControl.GotFocus    += (sender, e) => this.SelectNextControl(tabControl, true, true, true, true);
            tabControl.Deselecting += (sender, e) =>
            {
                if (e.TabPage == tabPageDetailEdit)
                {
                    if (string.IsNullOrEmpty(txbEdit.Text.Trim()) || ((currentPiece.Details != null &&
                                                                       string.Join("", currentPiece.Details) == string.Join("", txbEdit.Lines))))
                    {
                        return;
                    }
                    DialogResult ret = MessageBox.Show(
                        "Your changes have not been saved; you want to save the changes?",
                        "Confirmation", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation);
                    switch (ret)
                    {
                    case DialogResult.Cancel:
                        e.Cancel = true;
                        txbEdit.Focus();
                        break;

                    case DialogResult.No:
                        UpdateDetail();
                        break;

                    case DialogResult.Yes:
                        ChangeDetail(txbEdit.Lines);
                        break;

                    default:
                        break;
                    }
                }
            };

            txbEdit.KeyDown += (sender, e) =>
            {
                if (e.KeyData == Keys.Escape)
                {
                    tabControl.SelectTab(0);
                }
                if (e.KeyData == (Keys.Control | Keys.Enter)) // submit changes and leave edit mode
                {
                    ChangeDetail(txbEdit.Lines);
                    tabControl.SelectTab(0);
                }
                if (e.KeyData == (Keys.Shift | Keys.Enter))
                {
                    ChangeDetail(txbEdit.Lines); // submit changes but not leaving edit mode
                }
            };

            txbEdit.PreviewKeyDown += (sender, e) =>
            {
                if (e.KeyData == (Keys.Shift | Keys.Enter) || e.KeyData == (Keys.Control | Keys.Enter))
                {
                    e.IsInputKey = false; //shift+enter and ctrl+enter is used for special purposes, not input...
                }
            };
            //txbEdit.GotFocus += (sender,e) => txbEdit.Lines = currentPiece.Details;

            pgrid.PropertyValueChanged += (sender, e) =>
            {
                change_status((e.OldValue != null ? e.OldValue.ToString() : "") + " => " + e.ChangedItem.Value.ToString());
                Array.ForEach <object>(pgrid.SelectedObjects, p => ((Piece)p).Commit());
                change_status("Properties updated");
            };
            ((ContainerControl)pgrid).Controls[2].PreviewKeyDown += (sender, e) =>
            {
                if (e.KeyData == Keys.Escape)
                {
                    dg.Focus();
                }
            };
        }