Ejemplo n.º 1
0
        public async Task GetAuction_CallsRepositoryGetAuctionWithCorrectArguments()
        {
            //arrange
            var groupCode = 1;
            var auctionId = 1;
            var mockRepo  = new Mock <IAuctionsRepository>();

            mockRepo.Setup(repo => repo.GetAuction(auctionId, groupCode)).Returns(Task.FromResult((Auction)null)).Verifiable();
            var userStoreMock   = new Mock <IUserStore <AppUser> >();
            var userManagerMock = new Mock <UserManager <AppUser> >(userStoreMock.Object, null, null, null, null, null, null, null, null);
            var auctions        = new Auctions(mockRepo.Object, userManagerMock.Object);
            //act
            await auctions.GetAuction(auctionId, groupCode);

            //assert
            mockRepo.Verify(repo => repo.GetAuction(auctionId, groupCode));
        }
Ejemplo n.º 2
0
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            user = MADUsers.GetUser();
            if (!MADRoles.UserHasRole("Auctioneers"))
            {
                FormsAuthentication.RedirectToLoginPage();
                Response.End();
                return;
            }

            string param = Page.RouteData.Values["auction_id"].ToString();

            if (String.IsNullOrEmpty(param))
            {
                param = Page.Request.QueryString["auction_id"];
            }


            Guid auctionID;

            if (!Guid.TryParse(param, out auctionID))
            {
                Response.StatusCode = 404;
                Response.End();
            }
            auction = Auctions.GetAuction(auctionID);
            if (auction == null)
            {
                Response.StatusCode = 404;
                Response.End();
            }
            if (auction.UserID != user.UserID)
            {
                Response.StatusCode = 403;
                Response.End();
            }

            lots = Auctions.GetAuctionLots(auction.AuctionID);

            AuctionTitle.Text           = auction.AuctionTitle;
            ShowAuctionLink.NavigateUrl = GetRouteUrl("ShowAuctionRoute", new { auction_id = auction.AuctionID.ToString() });


            if (!auction.IsStarted)
            {
                StatusButton.Text      = "Start auction";
                CreateLotBlock.Visible = true;
            }
            else if (!auction.IsClosed)
            {
                StatusButton.Text = "Close auction";
            }
            else
            {
                AuctionStatusBlock.Visible = false;
                CreateLotBlock.Visible     = false;
            }

            LotsRepeater.DataSource = lots;
            LotsRepeater.DataBind();
        }
Ejemplo n.º 3
0
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            string param = Page.RouteData.Values["auction_id"].ToString();

            if (String.IsNullOrEmpty(param))
            {
                param = Page.Request.QueryString["auction_id"];
            }

            Guid auctionID;

            if (Guid.TryParse(param, out auctionID))
            {
                auction = Auctions.GetAuction(auctionID);
                if (auction == null)
                {
                    Response.StatusCode = 404;
                    Response.End();
                }

                User currentUser = MADUsers.GetUser();
                if (currentUser == null || currentUser.UserID != auction.UserID)
                {
                    if (!auction.IsStarted)
                    {
                        Response.StatusCode = 404;
                        Response.End();
                    }
                    EditAuctionPlaceholder.Visible = false;
                }
                else
                {
                    EditAuctionPlaceholder.Visible = true;
                    EditAuctionLink.NavigateUrl    = GetRouteUrl("EditAuctionRoute", new { auction_id = auction.AuctionID.ToString() });
                }

                lots = Auctions.GetAuctionLots(auction.AuctionID);
                user = MADUsers.GetUser(auction.UserID);

                AuctioneerLabel.Text = user.UserName;

                AuctioneerLink.NavigateUrl = GetRouteUrl("ShowUserAuctionsRoute", new { user_name = user.UserName });
                AuctioneerLink.Text        = "Find other auctions from " + user.UserName;

                AuctionTitleLabel.Text = auction.AuctionTitle;

                AuctionStatusLabel.Text = !auction.IsStarted ?
                                          "Not started"
                    : !auction.IsClosed ?
                                          "Active since " + auction.StartDate.ToString()
                    : "Closed at " + auction.EndDate.ToString();

                LotsRepeater.DataSource = lots;
                LotsRepeater.DataBind();
            }
            else
            {
                Response.StatusCode = 404;
                Response.End();
            }
        }