private void btnSave_Click_1(object sender, RoutedEventArgs e)
        {
            String date = ((DateTime)dpkDate.SelectedDate).ToString("MM/dd/yyyy");
            DateTime startDate = DateTime.Parse(date + " " + startDateTextBox.Text);
            DateTime endDate = DateTime.Parse(date + " " + endDateTextBox.Text);
            int number = Convert.ToInt32(txtNumber.Text);
            Location location = (Location)(cmbLocation.SelectedItem);
            DateTime createDate = DateTime.Now;
            Company Company = currentCompany;
            Reservation newReservation = new Reservation();
            newReservation.Id = 0;
            newReservation.Number = number;
            newReservation.StartDate = startDate;
            newReservation.EndDate = endDate;
            newReservation.CompanyId = Company.Id;
            newReservation.Location = location;
            newReservation.CreateDate = createDate;

            if (viewModel.addReservation(newReservation) > 0)
            {
                MessageBoxResult msbResult = MessageBox.Show("Your reservation has been placed", "Success", MessageBoxButton.OK);

            }
            else
            {
                MessageBox.Show("The room is not available at the selected time. Please try a different time", "error");

            }
        }
    /// <summary>
    /// Evénement déclenché lors du clic sur le bouton Réserver
    /// </summary>
    /// <param name="sender">Objet ayant envoyé l'événement</param>
    /// <param name="e">Arguments d'événements</param>
    protected void BtnReserver_Click(object sender, EventArgs e)
    {
        string selectedMatch = RbList.SelectedValue;
        string numberPlace = TxbPlace.Text;
        string selectedPrix = DdlPrix.SelectedValue;
        Reservation reservationCreated = new Reservation();
        reservationCreated.Place = Convert.ToInt32(numberPlace);
        reservationCreated.Prix = (float) Convert.ToDouble(selectedPrix.Split(new char[]{' '})[0]) * reservationCreated.Place;

        ServiceReservationClient serviceReservation = null;
        try
        {
            serviceReservation = new ServiceReservationClient();
            if (-1 == serviceReservation.AddReservation(reservationCreated, 
                matches.Where(match => match.ToString() == selectedMatch).ToList()[0].Identifiant))
            {
                LbResultAdd.Text = "Le match est complet, impossible de réserver une place";
            }
        }
        catch (Exception ex)
        {
            throw;
        }
        finally
        {
            RbList.Items.Clear();
            LoadMatches();
            if (serviceReservation != null)
            {
                serviceReservation.Close();
            }
        }
        LbResultAdd.Text = "Réservation bien enregistrée";
    }
Beispiel #3
0
 public void Save(Reservation reservation)
 {
     if(reservation.IsValid())
     {
         ReservationRepo.Save(reservation);
     }
 }
 public void TestAddReservationOverbookMatchReturnsError()
 {
     Reservation reservation = new Reservation();
     reservation.Place = 455785;
     reservation.Prix = 2.75f;
     int result = serviceReservationClient.AddReservation(reservation, 0);
     Assert.AreEqual(result, -1);
 }
 public void AddReservation(Reservation res) {
     //Console.Error.WriteLine(string.Format("Adding {0}.", res));
     Reservations.Add(res);
     if (res.StartDay < MinDay)
         MinDay = res.StartDay;
     if (res.EndDay > MaxDay)
         MaxDay = res.EndDay;
 }
 public void TestAddReservationReturnsNoError()
 {
     Reservation reservation = new Reservation();
     reservation.Place = 1;
     reservation.Prix = 3.5f;
     int result = serviceReservationClient.AddReservation(reservation, 1);
     Assert.AreEqual(result, 0);
 }
Beispiel #7
0
 public ReservationListItemModel(Reservation reservation)
 {
     Id = reservation.Id;
     ReserverationId = reservation.ReservationId.ToString();
     HotelName = reservation.HotelName;
     Arrival = reservation.Arrival;
     Departure = reservation.Departure;
 }
 public void AddReservation(String username, int referenceNumber)
 {
     var reservation = new Reservation();
     reservation.reference_number = referenceNumber;
     reservation.creator = username;
     db.Reservations.InsertOnSubmit(reservation);
     db.SubmitChanges();
 }
Beispiel #9
0
        public int Add(Reservation reservation)
        {
            this.reservations.Add(reservation);
            this.reservations.Save();

            return this.reservations.All()
                .OrderByDescending(r => r.Id)
                .FirstOrDefault().Id;
        }
        public static void book(HotelReservation hotel, FlightReservation flight)
        {
            Reservation reservation = new Reservation();
            reservation.Flight = flight;
            reservation.Hotel = hotel;

            MessageQueue queue = new MessageQueue(Reservation.QUEUE_PATH);
            queue.Send(reservation);
        }
 public ActionResult Edit(Reservation reservation)
 {
     if (ModelState.IsValid)
     {
         db.Entry(reservation).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(reservation);
 }
Beispiel #12
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            Page.Validate("vgPrimaryAdd");
            if(Page.IsValid)
            {
                Reservation r = new Reservation();
                r.UserId = Guid.Parse(Membership.GetUser().ProviderUserKey.ToString());
                r.SubjectId = Convert.ToInt32(ddlSubject.SelectedValue);
                r.ExperimentNo = txtExpNo.Text;
                r.DateRequested = DateTime.Now;
                r.DateFrom = Convert.ToDateTime(txtDateNeeded.Text);
                r.DateTo = Convert.ToDateTime(txtDateNeededTo.Text);
                r.LabRoom = txtLabRoom.Text;
                r.ApprovalStatus = "Pending";
                r.IsReleased = false;
                r.IsReturned = false;


                db.Reservations.InsertOnSubmit(r);
                db.SubmitChanges();

                int reserveId = r.Id;

                gvInv.AllowPaging = false;
                gvInv.DataBind();

                //reserve selected items
                foreach (GridViewRow row in gvInv.Rows)
                {
                    string quantity = "";
                    string quantityByGroup = "";
                    int invId = Convert.ToInt32(((Label)row.FindControl("lblRowId")).Text);

                    if (
                        (quantity = ((TextBox)row.FindControl("txtQuantityToBorrow")).Text) != String.Empty &&
                        (quantityByGroup = ((TextBox)row.FindControl("txtQuantityToBorrowByGroup")).Text) != String.Empty
                       )
                    {
                        ReservationItem ri = new ReservationItem();
                        ri.InventoryId = invId;
                        ri.Quantity = Convert.ToInt32(quantity);
                        ri.ReservationId = reserveId;
                        ri.QuantityByGroup = Convert.ToInt32(quantityByGroup);

                        db.ReservationItems.InsertOnSubmit(ri);
                        db.SubmitChanges();
                    }
                }

                gvInv.AllowPaging = true;
                gvInv.DataBind();

                Response.Redirect("~/reserve/default.aspx");
            }
        }
        public ActionResult Create(Reservation reservation)
        {
            if (ModelState.IsValid)
            {
                db.Reservations.Add(reservation);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(reservation);
        }
Beispiel #14
0
        public Reservation SetReservationInsertData()
        {
            var list = new Entity();
            Reservation reservation = new Reservation()
            {
                Lecturer_id = Convert.ToInt32(HttpContext.Current.Session[SessionEnum.SessionNames.LecturorsID.ToString()]),
                Slot_id = Convert.ToInt32(HttpContext.Current.Session[SessionEnum.SessionNames.SlotsID.ToString()])
            };
            list.dataClassContext.Reservations.InsertOnSubmit(reservation);
            list.dataClassContext.SubmitChanges();

            return reservation;
        }
Beispiel #15
0
        public List<Slot> GetSlotObjectsForReservation(Reservation res)
        {
            List<Slot> slotlist = new List<Slot> ();

            // Iterate through the slot number-to-object map
            // TODO: Probably need sanity checks here
            foreach (int i in res.m_slotNumberList)
            {
                slotlist.Add (m_numberToSlotMap[i]);
            }

            return slotlist;
        }
Beispiel #16
0
        public void SendReservationEmailToCustomer(Hotel hotel, Reservation reservation)
        {
            dynamic email = SendGridEmailService.CreateEmail("reservation_confirmation_hotel_html");
            email.Hotel = hotel;
            email.Reservation = reservation;

            var message = SendGridEmailService.RenderEmail(email);

            message.From = new MailAddress(hotel.Email);
            message.AddTo(reservation.Email);

            message.Subject = "Your reservation at " + hotel.Name;

            SendGridEmailService.Send(message);
        }
Beispiel #17
0
        private void saveReservation(Reservation reservation)
        {
            //using (var txScope = new TransactionScope())
            {
                var hotelRes = new libHotelReservations.Models.HotelReservation();
                hotelRes.DepartureDate = reservation.Hotel.DepartureDate;
                hotelRes.ArrivalDate = reservation.Hotel.ArrivalDate;
                hotelRes.HotelId = reservation.Hotel.HotelId;
                hotels.book(hotelRes);

                var flightRes = new libFlightReservations.Models.FlightReservation();
                flightRes.DepartureDate = reservation.Flight.DepartureDate;
                flightRes.ArrivalDate = reservation.Flight.ArrivalDate;
                flightRes.FlightId = reservation.Flight.FlightId;
                flights.book(flightRes);
            }
        }
        public ActionResult Create(Reservation reservation, int DemandeId)
        {
            var origEnsId = reservation.Enseignement.Id;

            reservation.Creneau = this.creneauxRepository.Find(reservation.Creneau.Id);
            reservation.Salle = this.sallesRepository.Get(reservation.Salle.Id);

            System.Diagnostics.Debug.WriteLine(origEnsId);
            reservation.Enseignement = this.ensRepository.Get(origEnsId);

            if (ModelState.IsValid)
            {
                this.repository.Insert(reservation);
                this.repository.Save();

                // Edit associated dmeande

                var d = this.demandesRepository.FindEager(DemandeId);
                d.ReservationAssociee = reservation;
                this.demandesRepository.Edit(d);
                this.demandesRepository.Save();

                return RedirectToAction("Index");
            }

            foreach (ModelState modelState in ViewData.ModelState.Values)
            {
                foreach (ModelError modelError in modelState.Errors)
                {
                    System.Diagnostics.Debug.WriteLine(modelError.ErrorMessage);
                }
            }

            var demandeAssociee = this.demandesRepository.Find(1);
            List<Salle> salles = this.sallesRepository.GetSallesCriteres(demandeAssociee.CapaciteNecessaire, demandeAssociee.BesoinProjecteur, demandeAssociee.DateVoulue).ToList();
            List<CreneauHoraire> creneaux = this.creneauxRepository.getCreneauxHorairesForDate(demandeAssociee.DateVoulue).ToList();

            ViewBag.demandeAssociee = demandeAssociee;
            ViewBag.salles = salles;
            ViewBag.creneaux = creneaux;

            return View(reservation);
        }
        public ReservationFrm(Reservation reservation)
        {
            InitializeComponent();
            this.reservation = reservation;

            //binding
            if (reservation.Number != null && reservation.StartDate != null && reservation.EndDate != null)
            {
                lblCompany.Content = Global.companies.Find(c => c.Id == reservation.CompanyId).Name;
                tboNumber.Text = reservation.Number.ToString();
                dateStart.Value = (DateTime)reservation.StartDate;
                dateEnd.Value = (DateTime)reservation.EndDate;
            }
            else
            {
                lblCompany.Content = Global.user.Company.Name;
                dateStart.Value = (DateTime)reservation.StartDate;
                dateEnd.Value = (DateTime)reservation.EndDate;
            }

            //add locations to combobox
            loadLocations();
            cboLocation.ItemsSource = Global.locations;
            cboLocation.DisplayMemberPath = "Name";
            cboLocation.SelectedValuePath = "id";

            if (reservation.Location != null)
            {
                // preselect company and formula
                if (reservation.Location.Id != 0)
                {
                    for (int i = 0; i < Global.locations.Count; i++)
                    {
                        if (Global.locations[i].Id == reservation.Location.Id)
                            cboLocation.SelectedIndex = i;
                    }
                }
            }
            else if (cboLocation.Items.Count > 0)
            {
                cboLocation.SelectedIndex = 0;
            }
        }
Beispiel #20
0
        public ReservationModel(Reservation reservation)
        {
            Id = reservation.Id;

            HotelName = reservation.HotelName;
            HotelAddress = reservation.HotelAddress;
            HotelPhoneNumber = reservation.HotelPhoneNumber;
            HotelEmail = reservation.HotelEmail;

            Arrival = reservation.Arrival;
            Departure = reservation.Departure;

            Fullname = reservation.Firstname + " " + reservation.Lastname;
            Email = reservation.Email;

            CreditcardHolder = reservation.CreditCardHolder;
            CreditcardNumber = reservation.CreditcardNumberObfuscated;
            ExpireMonth = reservation.CreditCardMonth;
            ExpireYear = reservation.CreditCardYear;
            CVC = reservation.CreditCardCvc;
        }
 public Reservation_edit(BL_ServiceReference.BL_SOAPClient BLin, Reservation r)
 {
     myBL = BLin;
     add = false;
     InitializeComponent();
     reservationIDTextBox.Text = r.ReservationID.ToString();
     reservationIDTextBox.Enabled = false;
     agencyIDComboBox.DataSource = myBL.Agencies();
     agencyIDComboBox.DisplayMember = "Name";
     agencyIDComboBox.ValueMember = "AgencyID";
     agencyIDComboBox.SelectedValue = r.AgencyID;
     agencyIDComboBox.Enabled = false;
     contactPersonTextBox.Text = ((Tour_Agency)agencyIDComboBox.SelectedItem).ContactPerson;
     arrivalDateDateTimePicker.Value = r.ArrivalDate;
     arrivalDateDateTimePicker.MaxDate = r.LeavingDate;
     leavingDateDateTimePicker.Value = r.LeavingDate;
     leavingDateDateTimePicker.MinDate = r.ArrivalDate;
     var v = myBL.availableRooms(arrivalDateDateTimePicker.Value, leavingDateDateTimePicker.Value, null);
     List<Room> localRooms = new List<Room>();
     if (r is Single_Reservation)
     {
         localRooms.Add(((Single_Reservation)r).Room);
         isSingle = true;
     }
     else if (r is Group_Reservation)
     {
         localRooms.AddRange(((Group_Reservation)r).Rooms);
         isSingle = false;
     }
     v.InsertRange(0, localRooms);
     roomsListBox.DataSource = (v);
     roomsListBox.DisplayMember = "RoomID";
     roomsListBox.ValueMember = "RoomID";
     for (int i = 0; i < localRooms.Count; i++)
         roomsListBox.SetItemChecked(i, true);
     bedsRefresh(localRooms);
     priceRefresh(localRooms);
 }
 public Reservation AddReservation(Reservation reservation)
 {
     //TODO: should check for penalties
     _reservationsRepository.AddReservation(reservation);
     return(reservation);
 }
Beispiel #23
0
        public ActionResult Post(Reservation reservation)
        {
            service.Create(reservation);

            return(Ok(reservation));
        }
Beispiel #24
0
 public IActionResult AddReservation(Reservation reservation)
 {
     Repository.AddReservation(reservation);
     return(RedirectToAction("Index"));
 }
 public IHttpActionResult AddReservation([FromBody] Reservation model)
 {
     _context.Reservations.Add(model);
     _context.SaveChanges();
     return(Json(_context.Reservations.ToArray()));
 }
 public Reservation RetrieveById(Reservation reservation) => reservationCrud.Retrieve <Reservation>(reservation);
 public void Delete(Reservation reservation) => reservationCrud.Delete(reservation);
Beispiel #28
0
 public void EmitInt(Reservation reservation, int emit)
 {
     int offset = ReturnReservationTicket(reservation);
     _data[offset] = (byte)(emit & 0xFF);
     _data[offset + 1] = (byte)((emit >> 8) & 0xFF);
     _data[offset + 2] = (byte)((emit >> 16) & 0xFF);
     _data[offset + 3] = (byte)((emit >> 24) & 0xFF);
 }
 public async Task<bool> CreateReservationAsync(Reservation reservation)
 {
     await _dbContext.Reservations.AddAsync(reservation);
     int created = await _dbContext.SaveChangesAsync();
     return created > 0;
 }
 public override int GetHashCode() {
   int hash = 1;
   if (reservation_ != null) hash ^= Reservation.GetHashCode();
   if (reservationSource_ != null) hash ^= ReservationSource.GetHashCode();
   return hash;
 }
Beispiel #31
0
 /// <summary>
 /// Add reservation to database
 /// </summary>
 /// <param name="reservation"></param>
 public void AddReservation(Reservation reservation)
 {
     _context.Reservations.Add(reservation);
     _context.SaveChanges();
 }
Beispiel #32
0
 public bool InsertReservation(Reservation r)
 {
     r.CustomerId = 1;
     return(ResSer.InsertReservation(r));
 }
Beispiel #33
0
 public HttpResponseMessage BookTable(Reservation reservationDetails)
 {
     return(Request.CreateResponse(HttpStatusCode.OK, "success"));
 }
        //TODO :Lab 02 Exercise 1, Task 4.5 : unmark the Add Method

        public void Add(Reservation entity)
        {
            context.Reservations.Add(entity);
        }
 public Reservation CreateSubreservation(Reservation reservation, User user) => reservationCrud.CreateSubreservation <Reservation>(reservation, user);
 public async Task<int> CreateAsync(Reservation reservation)
 {
     _context.Reservations.Add(reservation);
     return await _context.SaveChangesAsync();
 }
 public void Update(Reservation reservation) => reservationCrud.Update(reservation);
Beispiel #38
0
 public string CreateReservationByObject(Reservation tmpReservation) {
     object[] results = this.Invoke("CreateReservationByObject", new object[] {
                 tmpReservation});
     return ((string)(results[0]));
 }
 public Reservation Create(Reservation reservation) => reservationCrud.CreateReservationReturn <Reservation>(reservation);
Beispiel #40
0
 public void CreateReservationByObjectAsync(Reservation tmpReservation) {
     this.CreateReservationByObjectAsync(tmpReservation, null);
 }
 public ReservationReleased(Resource resource, Reservation reservation)
 => (Resource, Reservation) = (resource, reservation);
        public bool CanAccept(Reservation reservation)
        {
            var canReservationBeAccepted = _tables.Any(x => x.CanAccept(reservation));

            return(canReservationBeAccepted);
        }
Beispiel #43
0
        public void CreateReservation()
        {
            string numberRoom   = "";
            string dateCheckIn  = "";
            string dateCheckOut = "";

            ShowListRooms();
            Console.WriteLine("");
            Console.Write("\n > Digite o Nº do quarto: ");
            try { numberRoom = Console.ReadLine(); } catch { }

            var room = _hotel.FindRoom(numberRoom);

            if (room == null || room.isOcupedid)
            {
                Console.WriteLine("");
                Console.WriteLine("Nº de quarto indisponível");
                Console.Write("\nPressione Enter...");
                Console.ReadKey();
                return;
            }

            Console.Clear();
            Console.WriteLine("");

            var client = findClient();

            if (client == null)
            {
                Console.Clear();
                Console.WriteLine("");
                Console.WriteLine("Cliente não possui cadastro. Vamos iniciar o registro agora.");
                client = registerClient();
            }

            Console.Write("\n > Digite a data de Check-In (DD-MM-YYYY): ");
            try { dateCheckIn = Console.ReadLine(); } catch { }

            Console.Write("\n > Digite a data de Check-Out (DD-MM-YYYY): ");
            try { dateCheckOut = Console.ReadLine(); } catch { }

            var reservation = new Reservation(
                client,
                Formatter.StringToDate(dateCheckIn),
                Formatter.StringToDate(dateCheckOut),
                room
                );

            ShowDetailsReservation(reservation);
            ShowDetailsRoom(reservation.Room);

            Console.Write("\n > Confirma a reserva? (S/N): ");
            string confirmarPedido = "";

            try
            {
                confirmarPedido = Console.ReadLine().ToUpper();
            }
            catch { }

            if (confirmarPedido == "S")
            {
                reservation.Room.isOcupedid = true;
                reservation.Status          = Status.Open;
                client.Reservations.Add(reservation);
                _hotel.Reservations.Add(reservation);

                // Simula se o valor da reserva foi creditado e o valor creditado.
                reservation.SimulatorPayment();

                Persistence.GetInstance.Save();

                Console.WriteLine("");
                Console.WriteLine($"Reserva {reservation.Id} realizada com sucesso!");
                Console.Write("\nPressione Enter...");
                Console.ReadKey();
                return;
            }
            else
            {
                Console.WriteLine("");
                Console.WriteLine($"Transação não confirmada.");
                Console.Write("\nPressione Enter...");
                Console.ReadKey();
                return;
            }
        }
        /// <summary>
        ///  Creates a new reservation.
        /// </summary>
        /// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="body">Reservation Data</param>
        /// <returns>Task of ApiResponse (ReservationsResponse)</returns>
        public async System.Threading.Tasks.Task <ApiResponse <ReservationsResponse> > CreateReservationAsyncWithHttpInfo(Reservation body)
        {
            // verify the required parameter 'body' is set
            if (body == null)
            {
                throw new ApiException(400, "Missing required parameter 'body' when calling ReservationApi->CreateReservation");
            }

            var    localVarPath         = "/reservations";
            var    localVarPathParams   = new Dictionary <String, String>();
            var    localVarQueryParams  = new Dictionary <String, String>();
            var    localVarHeaderParams = new Dictionary <String, String>(Configuration.DefaultHeader);
            var    localVarFormParams   = new Dictionary <String, String>();
            var    localVarFileParams   = new Dictionary <String, FileParameter>();
            Object localVarPostBody     = null;

            // to determine the Content-Type header
            String[] localVarHttpContentTypes = new String[] {
                "application/json"
            };
            String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes);

            // to determine the Accept header
            String[] localVarHttpHeaderAccepts = new String[] {
                "application/json"
            };
            String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts);

            if (localVarHttpHeaderAccept != null)
            {
                localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept);
            }

            // set "format" to json by default
            // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
            localVarPathParams.Add("format", "json");
            if (body != null && body.GetType() != typeof(byte[]))
            {
                localVarPostBody = Configuration.ApiClient.Serialize(body); // http body (model) parameter
            }
            else
            {
                localVarPostBody = body; // byte array
            }


            // make the HTTP request
            IRestResponse localVarResponse = (IRestResponse)await Configuration.ApiClient.CallApiAsync(localVarPath,
                                                                                                       Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
                                                                                                       localVarPathParams, localVarHttpContentType);

            int localVarStatusCode = (int)localVarResponse.StatusCode;

            if (ExceptionFactory != null)
            {
                Exception exception = ExceptionFactory("CreateReservation", localVarResponse);
                if (exception != null)
                {
                    throw exception;
                }
            }

            return(new ApiResponse <ReservationsResponse>(localVarStatusCode,
                                                          localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
                                                          (ReservationsResponse)Configuration.ApiClient.Deserialize(localVarResponse, typeof(ReservationsResponse))));
        }
Beispiel #45
0
        public ActionResult <Reservation> AddReservation(Reservation reservation)
        {
            Reservation added = reservationDao.Create(reservation);

            return(Created($"/reservations/{added.Id}", added));
        }
        /// <summary>
        ///  Creates a new reservation.
        /// </summary>
        /// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="body">Reservation Data</param>
        /// <returns>Task of ReservationsResponse</returns>
        public async System.Threading.Tasks.Task <ReservationsResponse> CreateReservationAsync(Reservation body)
        {
            ApiResponse <ReservationsResponse> localVarResponse = await CreateReservationAsyncWithHttpInfo(body);

            return(localVarResponse.Data);
        }
Beispiel #47
0
        public async Task <IActionResult> Edit(ReservationsEditViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var  userId = User.FindFirstValue(ClaimTypes.NameIdentifier);
            User user   = _context.Users.FirstOrDefault(x => x.Id == userId);
            Room room   = _context.Rooms.FirstOrDefault(x => x.Id == model.RoomId);

            room.IsFree = false;


            decimal       adults = 0, kids = 0;
            List <Client> clients = new List <Client>();
            Reservation   reser   = await this._context.Reservations
                                    .Include(res => res.Clients)
                                    .ThenInclude(client => client.Client)
                                    .SingleOrDefaultAsync(rese => rese.Id == model.Id);

            List <ClientReservation> cl   = _context.ClientReservations.Where(res => res.Reservation.Id == reser.Id).ToList();
            List <string>            clId = new List <string>();

            foreach (var c in cl)
            {
                clId.Add(c.Client.Id);
            }

            foreach (var c in clId)
            {
                Client client = new Client();
                client = _context.Clients.FirstOrDefault(x => x.Id == c);
                clients.Add(client);
            }
            foreach (var client in clients)
            {
                if (client.IsAdult)
                {
                    adults++;
                }
                else
                {
                    kids++;
                }
            }
            var     days  = (decimal)(model.ReleaseDate.Subtract(model.AccommodationDate.Date).TotalDays);
            decimal dueAm = days * (adults * room.PriceForAdult + kids * room.PriceForKid);

            reser.Id   = model.Id;
            reser.User = user;
            reser.Room = room;
            reser.AccommodationDate = model.AccommodationDate;
            reser.ReleaseDate       = model.ReleaseDate;
            reser.HaveBreakFast     = model.HaveBreakFast;
            reser.IsAllInclusive    = model.IsAllInclusive;
            reser.DueAmount         = dueAm;


            _context.Update(reser);
            await _context.SaveChangesAsync();


            return(RedirectToAction(nameof(All)));
        }
        /// <summary>
        ///  Creates a new reservation.
        /// </summary>
        /// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="body">Reservation Data</param>
        /// <returns>ReservationsResponse</returns>
        public ReservationsResponse CreateReservation(Reservation body)
        {
            ApiResponse <ReservationsResponse> localVarResponse = CreateReservationWithHttpInfo(body);

            return(localVarResponse.Data);
        }
 public async Task<bool> UpdateReservationAsync(Reservation newReservation)
 {
     _dbContext.Reservations.Update(newReservation);
     var updated = await _dbContext.SaveChangesAsync();
     return updated > 0;
 }
Beispiel #50
0
        public IActionResult Add([FromBody] Reservation reservation)
        {
            _reservationLogic.Reserve(reservation);

            return(new OkResult());
        }
Beispiel #51
0
 public void EmitShort(Reservation reservation, short emit)
 {
     int offset = ReturnReservationTicket(reservation);
     _data[offset] = (byte)(emit & 0xFF);
     _data[offset + 1] = (byte)((emit >> 8) & 0xFF);
 }
 private bool IsToDateInTargetReservationRange(DateTime reservationDate, Reservation targetReservation)
 {
     return(reservationDate > targetReservation.From && reservationDate < targetReservation.To);
 }
Beispiel #53
0
 public void AddReservation(Reservation reservation)
 {
     this.Reservation = reservation;
 }
Beispiel #54
0
 public Reservation ReceiveJson([FromBody] Reservation reservation)
 {
     reservation.ClientName = "Json";
     return(reservation);
 }
 public async Task<int> UpdateAsync(Reservation reservation)
 {
     _context.Entry(reservation).State = EntityState.Modified;
     return await _context.SaveChangesAsync();
 }
Beispiel #56
0
 public Reservation ReceiveXml([FromBody] Reservation reservation)
 {
     reservation.ClientName = "Xml";
     return(reservation);
 }
Beispiel #57
0
 public System.IAsyncResult BeginCreateReservationByObject(Reservation tmpReservation, System.AsyncCallback callback, object asyncState) {
     return this.BeginInvoke("CreateReservationByObject", new object[] {
                 tmpReservation}, callback, asyncState);
 }
        public ActionResult Thanks()
        {
            Reservation reservation = TempData["reservation1"] as Reservation;

            return(View(reservation));
        }
Beispiel #59
0
 public void CreateReservationByObjectAsync(Reservation tmpReservation, object userState) {
     if ((this.CreateReservationByObjectOperationCompleted == null)) {
         this.CreateReservationByObjectOperationCompleted = new System.Threading.SendOrPostCallback(this.OnCreateReservationByObjectCompleted);
     }
     this.InvokeAsync("CreateReservationByObject", new object[] {
                 tmpReservation}, this.CreateReservationByObjectOperationCompleted, userState);
 }
        private async void Purchase(object parameter)
        {
            try
            {
                TogglePurchaseCommandEnabled(false);

                if (IsValid())
                {
                    if (!await this.TravelerInfo.Save(parameter))
                    {
                        return;
                    }

                    var reservation = new Reservation()
                    {
                        TravelerId      = UserAuth.Instance.Traveler.TravelerId,
                        ReservationDate = DateTime.Now,
                        DepartureFlight = new FlightSchedule()
                        {
                            FlightInfo = new FlightInfo()
                            {
                                Departure        = this.Depart.Departure,
                                FlightScheduleId = this.Depart.FlightScheduleId
                            }
                        },
                    };

                    if (this.Return != null)
                    {
                        reservation.ReturnFlight = new FlightSchedule()
                        {
                            FlightInfo = new FlightInfo()
                            {
                                Departure        = this.Return.Departure,
                                FlightScheduleId = this.Return.FlightScheduleId
                            }
                        };
                    }

                    var response = await _data.CreateNewReservationAsync(reservation);

                    if (response != null)
                    {
                        CacheManager.Invalidate(CacheType.Categories);
                        CacheManager.Invalidate(CacheType.Reservations);

                        var msg = new Windows.UI.Popups.MessageDialog(ResourceHelper.ResourceLoader.GetString("FlightPurchaseCompleted"));
                        await msg.ShowAsync();
                    }

                    this.Frame.Navigate(typeof(TripListPage), true);
                }
                else
                {
                    var msg = new Windows.UI.Popups.MessageDialog(ResourceHelper.ResourceLoader.GetString("FlightPurchaseMissingFields"));
                    await msg.ShowAsync();
                }
            }
            finally
            {
                TogglePurchaseCommandEnabled(true);
            }
        }