Ejemplo n.º 1
0
        public App()
        {
            database = new RestaurantReservations();

            database = JsonConvert.DeserializeObject <RestaurantReservations>(JsonData.json);

            InitializeComponent();

            MainPage = new NavigationPage(new MainPage());
        }
Ejemplo n.º 2
0
 public static string HandleThree(string mail, RestaurantReservations hotelReservations)
 {
     mail = mail.Replace("-user-", hotelReservations.ApplicationUser.Name);
     mail = mail.Replace("-Name-", hotelReservations.Restaurant.Name);
     mail = mail.Replace("-Address-", hotelReservations.Restaurant.Address);
     mail = mail.Replace("-Tel1-", hotelReservations.Restaurant.Tel1);
     mail = mail.Replace("-ReservationDate-", hotelReservations.ReservationDate.ToString());
     mail = mail.Replace("-Date-", hotelReservations.Date.ToString());
     mail = mail.Replace("-Tabel-", hotelReservations.NumberOfTable.ToString());
     mail = mail.Replace("-PaymentType-", hotelReservations.PaymentType.ToString());
     return(mail);
 }
        public ActionResult Booking(RestaurantReservations reservation)
        {
            if (ModelState.IsValid)
            {
                if (reservation.Id == 0)
                {
                    _db.RestaurantReservationses.Add(new RestaurantReservations()
                    {
                        ApplicationUserId = ApplicationUserService.GetUserId(),
                        PaymentType       = reservation.PaymentType,
                        Date            = reservation.Date,
                        ReservationDate = DateTime.Now,
                        NumberOfTable   = reservation.NumberOfTable,
                        RestaurantId    = reservation.RestaurantId
                    });
                    _db.SaveChanges();
                    var body =
                        $"{MailService.HandleThree(FileService.ReadFile(Server.MapPath("~/Files/Emails/3.txt")), new RestaurantReservations() {NumberOfTable = reservation.NumberOfTable, PaymentType = reservation.PaymentType, Date = reservation.Date, ReservationDate = DateTime.Now, ApplicationUser = ApplicationUserService.GetUser(), Restaurant = _db.Restaurants.FirstOrDefault(l => l.Id == reservation.RestaurantId),})}";
                    MailService.SendMail(Services.ApplicationUserService.GetUser().Email,
                                         "Booking Confirmation", body);
                    return(View("BookingConfirm"));
                }
                else
                {
                    var currentUser   = ApplicationUserService.GetUserId();
                    var restaurantRes = _db.RestaurantReservationses.FirstOrDefault(l =>
                                                                                    l.Id == reservation.Id && l.ApplicationUserId == currentUser);
                    if (restaurantRes != null)
                    {
                        restaurantRes.NumberOfTable    = reservation.NumberOfTable;
                        restaurantRes.RestaurantId     = reservation.RestaurantId;
                        restaurantRes.PaymentType      = reservation.PaymentType;
                        restaurantRes.Date             = reservation.Date;
                        _db.Entry(restaurantRes).State = EntityState.Modified;
                        _db.SaveChanges();
                    }

                    return(RedirectToAction("Profile", "Manage"));
                }
            }

            return(RedirectToAction("Booking", new { Table = reservation.RestaurantId }));
        }