public ActionResult CreateBooking(int id, DateTime inputSDate, DateTime inputEDate)
        {
            ViewBag.FaultEx = "";
            try
            {
                Advertisement ad     = client.FindAdById(id);
                var           userId = Session["ID"];
                double        result = client.CalcPrice(inputSDate, inputEDate, ad.Price);

                Booking b = new Booking
                {
                    AdvertismentId = id,
                    EndDate        = inputEDate,
                    RentUserId     = Convert.ToInt32(userId),
                    StartDate      = inputSDate,
                    TotalPrice     = result,
                };


                client.CreateBooking(b);
                return(RedirectToAction("SearchAds", "Ads"));
            }

            catch (FaultException e)
            {
                ViewBag.FaultEx = e.Message;
                return(RedirectToAction("ViewAd", "Ads", new { ID = id }));
            }

            catch (Exception)
            {
                return(RedirectToAction("Index", "Home"));
            }
        }
Exemple #2
0
 private void DpEDate_OnCalendarClosed(object sender, RoutedEventArgs e)
 {
     try
     {
         lblTotal.Content = _bikeService.CalcPrice((DateTime)dpSDate.SelectedDate, (DateTime)dpEDate.SelectedDate, (double)lblPrice.Content);
     }
     catch (FaultException ex)
     {
         MessageBox.Show(ex.Message);
     }
 }