コード例 #1
0
        public void ReserveOffer()
        {
            service.ClearReservationTables();
            service.Save();

            bool actual = service.IsOfferReserved(1, 1, 1);

            Assert.IsFalse(actual);

            // Reserve attraction
            service.ReserveOffer(1, 1, 1);
            actual = service.IsOfferReserved(1, 1, 1);
            Assert.IsTrue(actual);
        }
コード例 #2
0
        public ActionResult Reserve(ReservationModel reserveModel)
        {
            if (reserveModel == null)
            {
                return(HttpNotFound());
            }
            tOferta offer    = reserveModel.Offer;
            int?    clientId = AuthorizeUtil.GetUserId(service, User);

            ViewBag.IsReserved = IsOfferReserved(offer.IDOferty);
            if (clientId == null)
            {
                return(RedirectToAction("Login", "Account"));
            }
            try
            {
                if (!service.IsOfferReserved(offer.IDOferty, reserveModel.PersonId, clientId.Value))
                {
                    service.ReserveOffer(offer.IDOferty, reserveModel.PersonId, clientId.Value);
                }
                ViewBag.ReserveMessage = "Offer is reserved";
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", "Failed to reserve offer: " + ex.Message);
            }
            return(View(reserveModel));
        }
コード例 #3
0
        protected void ConfirmButton_Click(object sender, EventArgs e)
        {
            int offerId;

            if (int.TryParse(OfferId.Value, out offerId))
            {
                var offer = service.FindOffer(offerId);
                if (offer != null)
                {
                    int?userId = AuthorizeUtil.GetUserId(service, User);
                    if (userId == null)
                    {
                        Response.Redirect("~/Account/Login");
                    }
                    pnlConfirm.Visible = false;
                    if (!IsOfferReserved(offerId))
                    {
                        tKlient client   = service.GetClientWithPersons(userId.Value);
                        int     personId = client.tOsoby.First().IDOsoby;
                        service.ReserveOffer(offerId, personId, client.IDKlienta);
                    }
                    Message.Text = "Offer has been reserved.";
                }
            }
        }