private async void ListView_ItemTapped(object sender, ItemTappedEventArgs e)
 {
     if (e.Item != null)
     {
         Model.Notations item = e.Item as Model.Notations;
         await Navigation.PushAsync(new NotationDetailsPage(item.Id));
     }
 }
        private async void frmNotationDetails_Load(object sender, EventArgs e)
        {
            if (_id != 0)
            {
                entity = await _serviceNotations.GetById <Model.Notations>(_id);

                if (entity != null)
                {
                    if (entity.Status == Model.ReviewStatus.Pending)
                    {
                        btnSave.Text      = "Approve";
                        btnReject.Visible = true;
                    }

                    txtTuning.Text            = entity.Tuning;
                    txtTuningDescription.Text = entity.TuningDescription;
                    txtContent.Text           = entity.NotationContent;

                    await LoadCmbSongs();

                    LoadNotationTypes();

                    foreach (var item in cmbSong.Items)
                    {
                        if ((item as Model.Songs).Id == entity.SongId)
                        {
                            cmbSong.SelectedItem = item;
                            break;
                        }
                    }
                    foreach (var item in cmbNotationType.Items)
                    {
                        if ((NotationType)item == entity.Type)
                        {
                            cmbNotationType.SelectedItem = item;
                            break;
                        }
                    }
                }
            }
            else
            {
                await LoadCmbSongs();

                LoadNotationTypes();
            }
        }
        private async void BtnReject_Click(object sender, EventArgs e)
        {
            if (!ValidateChildren())
            {
                return;
            }

            request.NotationContent   = txtContent.Text;
            request.Tuning            = txtTuning.Text;
            request.TuningDescription = txtTuningDescription.Text;
            request.SongId            = (cmbSong.SelectedItem as Model.Songs).Id;
            request.Type = (NotationType)cmbNotationType.SelectedItem;

            request.Status = Model.ReviewStatus.Rejected;

            entity = await _serviceNotations.Update <Model.Notations>(_id, request);

            if (entity != null)
            {
                MessageBox.Show("Notation rejected");
                DialogResult = DialogResult.OK;
            }
        }
        private async void BtnSave_Click(object sender, EventArgs e)
        {
            if (!ValidateChildren())
            {
                return;
            }

            request.NotationContent   = txtContent.Text;
            request.Tuning            = txtTuning.Text;
            request.TuningDescription = txtTuningDescription.Text;
            request.SongId            = (cmbSong.SelectedItem as Model.Songs).Id;
            request.Type = (NotationType)cmbNotationType.SelectedItem;

            request.Status = Model.ReviewStatus.Approved;

            if (_id == 0)
            {
                entity = await _serviceNotations.Insert <Model.Notations>(request);

                if (entity != null)
                {
                    MessageBox.Show("Notation added");
                    Close();
                }
            }
            else
            {
                entity = await _serviceNotations.Update <Model.Notations>(_id, request);

                if (entity != null)
                {
                    MessageBox.Show("Notation updated");
                    Close();
                }
            }
        }
Beispiel #5
0
 private void IncludeNotationStats(Model.Notations entity)
 {
     entity.Rating    = (int)Math.Round(_context.Ratings.Where(x => x.NotationId == entity.Id).Average(x => (double?)x.Rating) ?? 0);
     entity.Favorites = _context.Favorites.Count(x => x.NotationId == entity.Id);
     entity.Views     = _context.NotationViews.Count(x => x.NotationId == entity.Id);
 }