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); }
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)); }
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."; } } }