public ActionResult Reserve(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tAtrakcjeUslugi attraction = service.FindAttraction(id.Value);

            if (attraction == null)
            {
                return(HttpNotFound());
            }
            int?userId = AuthorizeUtil.GetUserId(service, User);

            if (userId == null)
            {
                return(RedirectToAction("Login", "Account"));
            }
            tKlient client   = service.GetClientWithPersons(userId.Value);
            int     personId = client.tOsoby.First().IDOsoby;

            ConfigureViewBag(attraction, userId);
            return(View(new ReservationModel {
                Attraction = attraction, ClientWithPersons = client, PersonId = personId
            }));
        }
Exemplo n.º 2
0
        public ActionResult Reserve(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tOferta tOferta = service.FindOffer(id.Value);

            if (tOferta == null)
            {
                return(HttpNotFound());
            }
            int?userId = AuthorizeUtil.GetUserId(service, User);

            if (userId == null)
            {
                return(RedirectToAction("Login", "Account"));
            }
            tKlient client   = service.GetClientWithPersons(userId.Value);
            int     personId = client.tOsoby.First().IDOsoby;

            ViewBag.IsReserved = IsOfferReserved(id.Value);
            return(View(new ReservationModel {
                Offer = tOferta, ClientWithPersons = client, PersonId = personId
            }));
        }
        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.";
                }
            }
        }
        protected void ConfirmButton_Click(object sender, EventArgs e)
        {
            int attractionId;

            if (int.TryParse(AttractionId.Value, out attractionId))
            {
                var attraction = service.FindAttraction(attractionId);
                if (attraction != null)
                {
                    if (IsOfferReserved(attraction.IDAtrakcjiUslugi))
                    {
                        int?userId = AuthorizeUtil.GetUserId(service, User);
                        if (userId == null)
                        {
                            Response.Redirect("~/Account/Login");
                        }
                        pnlConfirm.Visible = false;
                        if (!IsAttractionReserved(attractionId))
                        {
                            tKlient client   = service.GetClientWithPersons(userId.Value);
                            int     personId = client.tOsoby.First().IDOsoby;
                            service.ReserveAttraction(attractionId, personId, client.IDKlienta);
                        }
                        Message.Text = "Offer has been reserved.";
                    }
                    else
                    {
                        pnlConfirm.Visible = false;
                        Message.Text       = "Offer related to this attraction has to be reserved first.";
                    }
                }
            }
        }