コード例 #1
0
ファイル: PromoTest.cs プロジェクト: ut786/ZATAppApi
        public void GetPromoCodeByCode_Test()
        {
            //arrange
            PromoCode expected = new PromoCode(2);
            //act
            PromoCode actual = PromoCode.GetPromoCode("TestPromo");

            //assert
            Assert.Equal(expected.PromoId, actual.PromoId);
        }
コード例 #2
0
        public double GetDiscountPrice(string roomType, int days, string promo)
        {
            var initialPrice = GetRoomPrice(roomType, days);

            // Retrieve PromoCode Object
            PromoCode resPromoCode = _promoCodeService.GetPromoCode(promo);

            // get the last two digit of the promo Code which will be the discount % and factor into room price
            var discount = (int)resPromoCode.GetPromoCode()["discount"];

            return(initialPrice - (initialPrice * (discount / 100.0)));
        }
コード例 #3
0
 public IHttpActionResult AddPromo(long id, string code)
 {
     try
     {
         Ride ride = new Ride(id);
         return(Ok(ride.AddPromo(PromoCode.GetPromoCode(code))));
     }
     catch (Exception ex)
     {
         return(InternalServerError(ex));
     }
 }
コード例 #4
0
ファイル: RidesController.cs プロジェクト: ut786/ZATAppApi
 public ActionResult ClosePromo(string code)
 {
     try
     {
         PromoCode promo = PromoCode.GetPromoCode(code);
         promo.IsOpen = false;
         return(RedirectToAction("ViewPromos"));
     }
     catch (Exception ex)
     {
         return(RedirectToAction("ErrorPage", "Error", ex));
     }
 }
コード例 #5
0
ファイル: RidesController.cs プロジェクト: ut786/ZATAppApi
 public ActionResult RiderDetails(BookRideViewModel model)
 {
     if (!ModelState.IsValid)
     {
         return(View(model));
     }
     try
     {
         //create rider
         Rider rider = new Rider(new User.NameFormat {
             FirstName = model.RiderFirstName, LastName = model.RidierLastName
         }, new User.ContactNumberFormat(model.CountryCode, model.CompanyCode, model.Number));
         //Book Ride
         var ride = rider.BookRide(new Ride.RideBookingDetails
         {
             Destination = new Location {
                 Latitude = model.DLat, Longitude = model.Dlng
             },
             PickUpLocation = new Location {
                 Latitude = model.PLat, Longitude = model.Plng
             },
             VehicleType = new VehicleType(model.VehicleType)
         });
         //Add Promo
         if (model.PromoCode != null || model.PromoCode == String.Empty)
         {
             ride.AddPromo(PromoCode.GetPromoCode(model.PromoCode));
         }
         return(RedirectToAction("BookRide"));
     }
     catch (UniqueKeyViolationException ex)
     {
         ModelState.AddModelError(String.Empty, ex.Message);
         return(View(model));
     }
     catch (UnsuccessfullProcessException)
     {
         ModelState.AddModelError(String.Empty, "Seems like no driver is available near the pick-up point.");
         return(View(model));
     }
     catch (Exception ex)
     {
         return(RedirectToAction("ErrorPage", "Error", ex));
     }
 }