Ejemplo n.º 1
0
        protected void AddToCart_Click(object sender, EventArgs e)
        {
            MessageUserControl.TryRun((Northwind.UI.ProcessRequest)(() =>
            {
                if (User.IsInRole(Settings.EmployeeRole))
                {
                    throw new Exception("Employees are not allowed to shop online!");
                }
                if (User.IsInRole(Settings.CustomerRole))
                {
                    SalesController controller = new SalesController();
                    var gridView = (GridViewRow)((Button)sender).NamingContainer;
                    var userName = User.Identity.Name;
                    int partId   = int.Parse((gridView.FindControl("PartID") as HiddenField).Value);
                    int qty      = int.Parse((gridView.FindControl("QTY") as TextBox).Text);
                    if (qty <= 0)
                    {
                        throw new Exception("You maus add only positive amount");
                    }
                    controller.AddToCart(userName, partId, qty);

                    var shoppingCartId      = controller.RetriveShoppingCartId(userName);
                    List <PartPoco> parts   = controller.ListAllParts((int)shoppingCartId);
                    PartGridView.Visible    = true;
                    PartGridView.DataSource = parts;
                    PartGridView.DataBind();
                }
                else
                {
                    throw new Exception("You must be a customer to make an online purchase");
                }
            }), "Added succesfully", "The items added to your cart");
        }
Ejemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SalesController controller = new SalesController();

            //CatGridView.Columns[0].HeaderText = "All";
            CatGridView.Columns[2].HeaderText = controller.PartsCount().ToString();
            // Secure access to this page
            if (!Request.IsAuthenticated ||
                !User.IsInRole(Settings.CustomerRole)
                )
            {
                vieCart.Visible = false;
                List <PartPoco> parts = controller.ListAllParts();
                PartGridView.Visible    = true;
                PartGridView.DataSource = parts;
                PartGridView.DataBind();
                //Response.Redirect("~", true);
            }
            else
            {
                //customer entry
                var userName = User.Identity.Name;
                //retrive shopping cart info to display current items in cart
                var             shoppingCartId = controller.RetriveShoppingCartId(userName);
                List <PartPoco> parts          = controller.ListAllParts(shoppingCartId);

                PartGridView.Visible    = true;
                PartGridView.DataSource = parts;
                PartGridView.DataBind();
                //Response.Redirect("~", true);
            }
        }
Ejemplo n.º 3
0
        protected void PartGridView_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            SalesController controller = new SalesController();
            List <PartPoco> parts      = controller.ListAllParts();

            PartGridView.Visible    = true;
            PartGridView.PageIndex  = e.NewPageIndex;
            PartGridView.DataSource = parts;
            PartGridView.DataBind();
        }
Ejemplo n.º 4
0
        protected void CategoryDesc_Click(object sender, EventArgs e)
        {
            var grvRow = (GridViewRow)((LinkButton)sender).NamingContainer;
            var catId  = int.Parse((grvRow.FindControl("CategoryIdHidden") as HiddenField).Value);

            List <PartPoco> parts = null;

            MessageUserControl.TryRun((Northwind.UI.ProcessRequest)(() =>
            {
                SalesController controller = new SalesController();
                parts = controller.ListAllPartsByCatId((int)Convert.ToInt32((int)catId));
                if (parts == null)
                {
                    throw new Exception("There are no parts in this category");
                }
                else
                {
                    PartGridView.Visible    = true;
                    PartGridView.DataSource = parts;
                    PartGridView.DataBind();
                }
            }));
        }
Ejemplo n.º 5
0
 private void VideoPlayer_PartSwitched(object sender, int e)
 {
     PartGridView.SelectedIndex = e;
     PartGridView.ScrollIntoView(VideoPartCollection[e], ScrollIntoViewAlignment.Leading);
 }
Ejemplo n.º 6
0
        public async Task <bool> Init(BangumiDetail detail, int partId)
        {
            Reset();
            App.AppViewModel.CurrentPlayerType  = Models.Enums.PlayerType.Bangumi;
            App.AppViewModel.CurrentVideoPlayer = VideoPlayer;
            _detail             = detail;
            TitleBlock.Text     = _detail.title;
            PlayCountBlock.Text = _detail.stat.play;
            TabletMainPage.Current.SetBackgroundImage(_detail.square_cover ?? _detail.cover);
            DanmakuCountBlock.Text = AppTool.GetNumberAbbreviation(_detail.stat.danmakus);
            RepostButton.Text      = AppTool.GetNumberAbbreviation(_detail.stat.share);
            CommentButton.Text     = AppTool.GetNumberAbbreviation(_detail.stat.reply);

            DescriptionBlock.Text = _detail.evaluate;
            ToolTipService.SetToolTip(DescriptionBlock, _detail.evaluate);

            if (_detail.rating != null)
            {
                ScoreBlock.Text      = _detail.rating.score.ToString();
                ScoreCountBlock.Text = AppTool.GetNumberAbbreviation(_detail.rating.count) + "人";
            }
            else
            {
                RatingContainer.Visibility = Visibility.Collapsed;
            }

            BasicInfoBlock.Text = $"{_detail.type_desc}\n{_detail.publish.release_date_show}\n{_detail.publish.time_length_show}";

            CoinButton.Text = AppTool.GetNumberAbbreviation(_detail.stat.coins);
            if (_detail.episodes != null && _detail.episodes.Count > 0)
            {
                PartGridView.Visibility = Visibility.Visible;
                _detail.episodes.ForEach(p => BangumiPartCollection.Add(p));
            }
            else
            {
                PartGridView.Visibility = Visibility.Collapsed;
            }
            if (isEp)
            {
                for (int i = 0; i < _detail.episodes.Count; i++)
                {
                    var part = _detail.episodes[i];
                    if (part.id == bangumiId)
                    {
                        _currentPart = part;
                        PartGridView.SelectedIndex = i;
                        PartGridView.ScrollIntoView(part, ScrollIntoViewAlignment.Leading);
                        break;
                    }
                }
                bangumiId = _detail.season_id;
            }
            else if (_detail.user_status.progress != null)
            {
                _currentPart = _detail.episodes.Where(p => p.id == _detail.user_status.progress.last_ep_id).FirstOrDefault();
                if (_currentPart != null)
                {
                    int lastIndex = _detail.episodes.IndexOf(_currentPart);
                    PartGridView.SelectedIndex = lastIndex - 1 < -1 ? -1 : lastIndex;
                    PartGridView.ScrollIntoView(_currentPart, ScrollIntoViewAlignment.Leading);
                }
            }

            if (_currentPart == null && _detail.episodes.Count > 0)
            {
                _currentPart = _detail.episodes.First();
                PartGridView.SelectedIndex = 0;
            }
            if (_detail.styles != null && _detail.styles.Count > 0)
            {
                TagGridView.Visibility = Visibility.Visible;
                _detail.styles.ForEach(p => TagCollection.Add(p));
            }
            else
            {
                TagGridView.Visibility = Visibility.Collapsed;
            }

            CheckFollowButton();

            if (_detail.limit != null)
            {
                await new ConfirmDialog(_detail.limit.content).ShowAsync();
                return(false);
            }
            await VideoPlayer.Init(_detail, _currentPart);

            return(true);
        }
Ejemplo n.º 7
0
        private async Task <bool> InitDetail()
        {
            TitleBlock.Text        = _detail.title;
            PlayCountBlock.Text    = _detail.stat.play;
            DanmukuCountBlock.Text = AppTool.GetNumberAbbreviation(_detail.stat.danmakus);
            RepostButton.Text      = AppTool.GetNumberAbbreviation(_detail.stat.share);
            CommentButton.Text     = AppTool.GetNumberAbbreviation(_detail.stat.reply);

            DescriptionBlock.Text = _detail.evaluate;
            ToolTipService.SetToolTip(DescriptionBlock, _detail.evaluate);

            if (_detail.rating != null)
            {
                ScoreBlock.Text      = _detail.rating.score.ToString();
                ScoreCountBlock.Text = AppTool.GetNumberAbbreviation(_detail.rating.count) + "人";
            }
            else
            {
                RatingContainer.Visibility = Visibility.Collapsed;
            }

            BasicInfoBlock.Text = $"{_detail.type_desc}\n{_detail.publish.release_date_show}\n{_detail.publish.time_length_show}";

            CoinButton.Text = AppTool.GetNumberAbbreviation(_detail.stat.coins);

            CoverImage.Source = new BitmapImage(new Uri(_detail.cover + "@200w.jpg"));

            Section1Title.Text   = _detail.actor.title;
            Section1Content.Text = _detail.actor.info;
            if (string.IsNullOrEmpty(_detail.actor.info))
            {
                Section1Container.Visibility = Visibility.Collapsed;
            }
            Section2Title.Text   = _detail.staff.title;
            Section2Content.Text = _detail.staff.info;
            if (string.IsNullOrEmpty(_detail.staff.info))
            {
                Section2Container.Visibility = Visibility.Collapsed;
            }

            _detail.episodes.ForEach(p => BangumiPartCollection.Add(p));
            if (isEp)
            {
                for (int i = 0; i < _detail.episodes.Count; i++)
                {
                    var part = _detail.episodes[i];
                    if (part.id == bangumiId)
                    {
                        _currentPart = part;
                        PartListView.SelectedIndex = PartGridView.SelectedIndex = i;
                        PartListView.ScrollIntoView(part, ScrollIntoViewAlignment.Leading);
                        PartGridView.ScrollIntoView(part, ScrollIntoViewAlignment.Leading);
                        break;
                    }
                }
                bangumiId = _detail.season_id;
            }
            else if (_detail.user_status.progress != null)
            {
                _currentPart = _detail.episodes.Where(p => p.id == _detail.user_status.progress.last_ep_id).FirstOrDefault();
                if (_currentPart != null)
                {
                    int lastIndex = _detail.episodes.IndexOf(_currentPart);
                    PartListView.SelectedIndex = PartGridView.SelectedIndex = lastIndex - 1 < -1 ? -1 : lastIndex;
                    PartListView.ScrollIntoView(_currentPart, ScrollIntoViewAlignment.Leading);
                    PartGridView.ScrollIntoView(_currentPart, ScrollIntoViewAlignment.Leading);
                }
            }

            if (_currentPart == null && _detail.episodes.Count > 0)
            {
                _currentPart = _detail.episodes.First();
                PartListView.SelectedIndex = PartGridView.SelectedIndex = 0;
            }
            if (_detail.styles != null && _detail.styles.Count > 0)
            {
                TagListView.Visibility = Visibility.Visible;
                _detail.styles.ForEach(p => TagCollection.Add(p));
            }
            else
            {
                TagListView.Visibility = Visibility.Collapsed;
            }

            CheckFollowButton();

            if (_detail.limit != null)
            {
                await new ConfirmDialog(_detail.limit.content).ShowAsync();
                return(false);
            }
            return(true);
        }