Ejemplo n.º 1
0
        public bool InsertReservation(Models.Reservation r)
        {
            using (PersonServiceClient proxy = new PersonServiceClient())
            {
                Reservation res = new Reservation();
                res.ReservationId = r.ReservationId;
                res.MovieId       = r.MovieId;
                res.Date          = r.Date;
                res.CustomerId    = r.CustomerId;
                res.Seats         = new List <Seat>();

                foreach (Models.Seat s in r.Seats)
                {
                    Seat seat = new Seat();
                    seat.HallId = s.HallId;
                    seat.Number = s.Number;
                    seat.ResId  = s.ResId;
                    seat.Row    = s.Row;
                    seat.SeatId = s.SeatId;
                    res.Seats.Add(seat);
                }

                return(proxy.InsertReservation(res));
            }
        }
        public ActionResult Index(Models.Reservation model)
        {
            if (ModelState.IsValid)
            {
                DAL.Models.Reservation reservation = new DAL.Models.Reservation()
                {
                    RentalStartDate = model.RentalStartDate,
                    RentalEndDate   = model.RentalEndDate,
                    Count           = model.Count,
                    TotalCost       = (decimal)Session["TotalCost"], //model.TotalCostString, nie mam pojecia dlaczego nawet w stringu niechce sie to przeslac,
                                                                     //bo w decimallu nie idzie bo ma problem konwertowac z przecinkiem na kropke, robie late
                    UserId      = (int)Session["UserId"],
                    BoardGameId = model.BoardGameId,
                };
                switch (reservationService.AddReservation(reservation))
                {
                case ReservationServiceResponse.SuccessReservation:
                    //string imagePath = model.ImagePath;
                    ModelState.Clear();
                    //ViewBag.ImagePath = imagePath;
                    TempData["SuccessReservation"] = $"Z powodzeniem dokonano rezerwacji: {model.BoardGameName}.";
                    return(RedirectToAction("Login", "Login"));

                case ReservationServiceResponse.NotEnoughBoardGame:
                    ViewBag.NotEnoughBoardGameMessage = "Nie posiadamy wystarczającej liczby gier.";
                    return(RedirectToAction("Details", "BoardGameDetailsOffer", new { boardGameId = model.BoardGameId }));

                default:
                    break;
                }
            }
            return(View(model));
        }
Ejemplo n.º 3
0
        public ActionResult Create()
        {
            var model = new Models.Reservation();

            //Reservation
            var reservations    = reservationRepository.GetAll();
            var reservationList = reservations.Select(r => new SelectListItem()
            {
                Value = r.Id.ToString()
            }).ToList();
            //Seat
            var seats    = seatRepository.GetAll();
            var seatList = seats.Select(s => new SelectListItem()
            {
                Value = s.Id.ToString(),
                Text  = s.SeatNo.ToString()
            }).ToList();

            //Show

            var shows    = showRepository.GetAll();
            var showList = shows.Select(s => new SelectListItem()
            {
                Value = s.Id.ToString(),
                Text  = s.Film.Name
            }).ToList();

            ViewBag.Reservations = reservationList;
            ViewBag.Seats        = seatList;
            ViewBag.Shows        = showList;

            return(View(model));
        }
Ejemplo n.º 4
0
 public ReservationsNurseController(ReservationsNurse view)
 {
     this.view             = view;
     this.reservationModel = new Models.Reservation();
     this.employeeModel    = new Models.Employee();
     this.nurseModel       = new Models.Nurse();
 }
Ejemplo n.º 5
0
        // GET: Reservation/Edit/5
        public ActionResult Edit(int id)
        {
            var reservation = reservationRepository.GetById(id);
            //Seat
            var seats = seatRepository.GetAll();
            var Seats = seats.Select(s => new SelectListItem()
            {
                Value = s.Id.ToString(),
                Text  = s.SeatNo.ToString()
            }).ToList();

            //Show

            var shows = showRepository.GetAll();
            var Shows = shows.Select(s => new SelectListItem()
            {
                Value = s.Id.ToString(),
                Text  = s.Film.Name
            }).ToList();

            ViewBag.Seats = Seats;
            ViewBag.Shows = Shows;

            if (reservation == null)
            {
                return(HttpNotFound());
            }

            var reservationId = new Models.Reservation();

            reservationId.InjectFrom(reservation);
            return(View(reservationId));
        }
        public async Task <bool> Handle(CreateReservationCommand request, CancellationToken cancellationToken)
        {
            _logger.LogInformation("CreateReservationCommandHandler Called");
            try
            {
                var reservation = new Models.Reservation
                {
                    Id         = request.Id,
                    ResourceId = request.ResourceId,
                    Timeslot   = request.Timeslot,
                    UserId     = request.UserId
                };

                await _reservationRepository.AddAsync(reservation);

                _eventBus.PublishEvent(new ReservationCreatedEvent(request.Id, request.UserId, request.ResourceId,
                                                                   request.Timeslot));
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }

            return(await Task.FromResult(true));
        }
Ejemplo n.º 7
0
 public void CancellReservation(Guid reservationId, int eventId)
 {
     Models.Reservation reservation = GetReservation(reservationId, eventId);
     if (reservation != null)    // reservation exists
     {
         reservation.Cancelled = true;
         try
         {
             mapper.Update(reservation);
             // return tickets to pool
             tickets_Counter.IncrementRemainingTicketsCountBy(reservation.Event_Id,
                                                              reservation.Tickets_count);
             Statistics.Cancelled(reservation.Event_Id, reservation.Tickets_count);
         }
         catch (Exception e)
         {
             Console.WriteLine(e.Message);
         }
     }
     else
     {
         Console.WriteLine("No such reservation found");
         Statistics.NotFound(eventId);
     }
 }
Ejemplo n.º 8
0
        public bool PlaceReservation(Models.Reservation reservation, int eventCapacity)
        {
            long?remainingTickets = tickets_Counter.GetCurrentTicketsCount(reservation.Event_Id);

            if (remainingTickets != null)   // counter exists
            {
                // are tickets still available
                if (eventCapacity - remainingTickets >= reservation.Tickets_count)
                {
                    mapper.Insert(reservation);
                    // get tickets from pool
                    tickets_Counter.DecrementRemainingTicketsCountBy(reservation.Event_Id,
                                                                     reservation.Tickets_count);
                    Statistics.Reservation(reservation.Event_Id);
                    // Statistics.Placed(reservation.Event_Id, reservation.Tickets_count);
                }
                else
                {
                    // Console.WriteLine("Tickets count exceeded");
                    Statistics.Declined(reservation.Event_Id, reservation.Tickets_count);
                    return(false);
                }
            }
            else
            {
                Console.WriteLine("Couldn't find ticketsCounter");
                return(false);
            }
            return(true);
        }
Ejemplo n.º 9
0
 public ReservationsController(ReservationsDoc view)
 {
     this.view             = view;
     this.reservationModel = new Models.Reservation();
     this.employeeModel    = new Models.Employee();
     this.doctorModel      = new Models.Doctor();
 }
Ejemplo n.º 10
0
        public ActionResult Index(Models.Reservation model)
        {
            if (ModelState.IsValid)
            {
                DAL.Models.Reservation reservation = new DAL.Models.Reservation()
                {
                    RentalStartDate = model.RentalStartDate,
                    RentalEndDate   = model.RentalEndDate,
                    Count           = model.Count,
                    TotalCost       = (decimal)Session["TotalCost"], //model.TotalCostString, nie mam pojecia dlaczego nawet w stringu niechce sie to przeslac,
                                                                     //bo w decimallu nie idzie bo ma problem konwertowac z przecinkiem na kropke, robie late
                    UserId      = (int)Session["UserId"],
                    BoardGameId = model.BoardGameId,
                };
                switch (reservationService.AddReservation(reservation))
                {
                case ReservationServiceResponse.SuccessReservation:
                    ModelState.Clear();
                    TempData["SuccessReservation"] = $"Succesfully reserved: {model.BoardGameName}.";
                    return(RedirectToAction("Login", "Login"));

                case ReservationServiceResponse.NotEnoughBoardGame:
                    ViewBag.NotEnoughBoardGameMessage = "We do not have enough board games.";
                    return(RedirectToAction("Details", "BoardGameDetailsOffer", new { boardGameId = model.BoardGameId }));

                default:
                    break;
                }
            }
            return(View(model));
        }
Ejemplo n.º 11
0
        private Models.Reservation GetReservationIfRoomNotAvailable(Models.Reservation reservation)
        {
            var roomNo       = reservation.Room.RoomNo;
            var reservations = GetReservationsByRoom(roomNo);

            return(reservations.FirstOrDefault(r =>
                                               r.CheckInDate != null && r.CheckInDate <= DateTime.Now && r.CheckOutDate == null));
        }
Ejemplo n.º 12
0
 public static Reservation ToReservation(this Models.Reservation reservation)
 {
     return(new Reservation()
     {
         Player = reservation.Player.ToPlayer(),
         Created = Timestamp.FromDateTime(reservation.Created)
     });
 }
 public ReservationsController(Reservations view)
 {
     this.view             = view;
     this.reservationModel = new Models.Reservation();
     this.serviceModel     = new Models.Service();
     this.patientModel     = new Models.Patient();
     this.doctorModel      = new Models.Doctor();
     this.nurseModel       = new Models.Nurse();
 }
Ejemplo n.º 14
0
        /**
         * Controller to handle reset button
         */

        public void handleResetButton()
        {
            this.view.SubmitBtn.Enabled             = true;
            this.view.DescriptionTxtBox.ReadOnly    = false;
            this.view.MedicamentsListBox.Enabled    = true;
            this.selectedReservation                = null;
            this.view.SelectedReservationLabel.Text = "-";
            this.view.DescriptionTxtBox.Text        = "";
        }
Ejemplo n.º 15
0
        public ActionResult Delete(int id, Models.Reservation reservation)
        {
            var reservationDelete = reservationRepository.FindById(id);

            reservationDelete.InjectFrom(reservation);
            reservationRepository.Delete(reservationDelete);
            TempData["message"] = string.Format("{0} has been saved", reservation.ShowName);
            unitOfWork.Commit();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 16
0
 public PrescriptionsController(Prescription view)
 {
     this.view                        = view;
     this.reservationModel            = new Models.Reservation();
     this.doctorModel                 = new Models.Doctor();
     this.allergenModel               = new Models.Allergen();
     this.medicamentModel             = new Models.Medicament();
     this.prescriptionModel           = new Models.Prescription();
     this.prescriptionMedicamentModel = new Models.PrescriptionMedicament();
 }
Ejemplo n.º 17
0
        public static Services.Models.Reservation CreateReservationDataModel(this Models.Reservation reservation)
        {
            var config = new MapperConfiguration(
                cfg =>
            {
                cfg.CreateMap <Models.Reservation, Services.Models.Reservation>()
                .ForMember(dest => dest.Id, opt => opt.MapFrom(src => int.Parse(src.Id)))
                .ForMember(dest => dest.VenueId, opt => opt.MapFrom(src => int.Parse(src.VenueId)))
                .ForMember(dest => dest.UserId, opt => opt.MapFrom(src => src.UserId))
                .ForMember(dest => dest.SeatNumber, opt => opt.MapFrom(src => src.SeatNumber));
            });

            return(config.CreateMapper().Map <Services.Models.Reservation>(reservation));
        }
Ejemplo n.º 18
0
        public MyCovoitAffichageDemandeTrajet()
        {
            InitializeComponent();
            Title = "Demandes de trajets :";
            List <Models.Reservation> lesReservations = new List <Models.Reservation>();

            lesReservations = Database.MyCovoit.getLesReservations();


            ScrollView scroll = new ScrollView();

            StackLayout stackLayout = new StackLayout();

            for (int i = 0; i < lesReservations.Count; i++)
            {
                Models.Reservation uneReservation = lesReservations[i];

                Frame Card = new Frame
                {
                    Margin          = new Thickness(40, 20, 40, 0),
                    BackgroundColor = Color.FromHex("#27ae60"),
                    CornerRadius    = 10,
                    HasShadow       = true
                };

                StackLayout stackCard = new StackLayout();

                StackLayout stakLabel = new StackLayout
                {
                    Padding       = new Thickness(15, 15, 15, -10),
                    HeightRequest = 140,
                    WidthRequest  = 100
                };

                Label labelTest = new Label
                {
                    TextColor = Color.White,
                    Text      = "Montée : " + uneReservation.getMonte().ToString() + "\n" +
                                "Descente : " + uneReservation.getDescente() + "\n" +
                                "Prix : " + uneReservation.getPrix().ToString() + "€" + "\n" +
                                "Conducteur : " + uneReservation.getConducteur(),
                    FontSize = 25
                };



                scroll.Content = stackLayout;
                Content        = scroll;
            }
        }
Ejemplo n.º 19
0
        // GET: Reservation/Delete/5
        public ActionResult Delete(int id)
        {
            var reservation = reservationRepository.FindById(id);

            if (reservationRepository == null)
            {
                return(HttpNotFound());
            }

            var reservationId = new Models.Reservation();

            reservationId.InjectFrom(reservation);
            return(View(reservationId));
        }
Ejemplo n.º 20
0
        private static long GetPriceOfRoom(Models.Reservation reservation)
        {
            var checkInDate  = reservation.CheckInDate;
            var checkOutDate = reservation.CheckOutDate;
            var days         = new int();


            if (checkInDate != null && checkOutDate != null)
            {
                days = ((TimeSpan)(checkOutDate - checkInDate)).Days;
            }

            return(days * reservation.Room.PricePerDay);
        }
Ejemplo n.º 21
0
        public async Task <IActionResult> Edit(int id, Models.Reservation Reservation)
        {
            try
            {
                _context.Reservation.Update(Reservation);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View());
            }
        }
Ejemplo n.º 22
0
        public RedirectToActionResult CreateReservation(ReservationViewModel reservation)
        {
            if (reservation.CheckInDate < DateTime.Today)
            {
                return(RedirectToAction("ReservationLate"));
            }

            else if (reservation.CheckInDate == reservation.CheckOutDate)
            {
                return(RedirectToAction("ReservationTooShort"));
            }

            else if (reservation.CheckInDate > reservation.CheckOutDate)
            {
                return(RedirectToAction("ReservationWronglyScheduled"));
            }

            else if (context.Reservations.Where(x => x.CheckInDate == reservation.CheckInDate && x.Room.RoomID == reservation.Room.RoomID).Any())
            {
                return(RedirectToAction("ReservationExists"));
            }

            else
            {
                Models.Reservation reservationModel = new Models.Reservation();

                reservationModel.Room         = context.Rooms.FirstOrDefault(x => x.RoomID == reservation.Room.RoomID);
                reservationModel.UserName     = userManager.GetUserName(User);
                reservationModel.CheckInDate  = reservation.CheckInDate;
                reservationModel.CheckOutDate = reservation.CheckOutDate;
                reservationModel.TotalPrice   = reservation.TotalPrice;
                reservationModel.CountDays    = reservation.CountDays;

                if (reservationModel.CheckInDate.HasValue && reservationModel.CheckOutDate.HasValue)
                {
                    DateTime dt1 = reservationModel.CheckInDate.Value;
                    DateTime dt2 = reservationModel.CheckOutDate.Value;

                    reservationModel.CountDays = (dt2 - dt1).Days;

                    reservationModel.TotalPrice = reservationModel.CountDays * reservationModel.Room.Price;

                    Reservation newReservation = _reservationRepository.Add(reservationModel);
                    context.SaveChanges();
                }
            }
            return(RedirectToAction("MyReservation"));
        }
Ejemplo n.º 23
0
        public ActionResult Edit(Models.Reservation reservation)
        {
            if (ModelState.IsValid)
            {
                var exists = reservationRepository.GetAll().Any(f => f.ShowId == reservation.ShowId && f.SeatId == reservation.SeatId);
                if (!exists)
                {
                    var reservationDb = reservationRepository.GetById(reservation.Id);
                    TryUpdateModel(reservationDb);
                    reservationService.UpdateReservation(reservationDb);
                    TempData["message"] = string.Format("{0} has been saved", reservation.ShowName);
                }

                else
                {
                    ModelState.AddModelError("SeatId", "This seat is already booked !");
                    ModelState.AddModelError("ShowId", "This show is already booked !");
                    //Seat
                    var seats    = seatRepository.GetAll();
                    var seatList = seats.Select(s => new SelectListItem()
                    {
                        Value = s.Id.ToString(),
                        Text  = s.SeatNo.ToString()
                    }).ToList();

                    //Show

                    var shows    = showRepository.GetAll();
                    var showList = shows.Select(s => new SelectListItem()
                    {
                        Value = s.Id.ToString(),
                        Text  = s.Film.Name
                    }).ToList();

                    ViewBag.Seats = seatList;
                    ViewBag.Shows = showList;
                    return(View(reservation));
                }
            }
            else
            {
                return(View(reservation));
            }

            return(RedirectToAction("Index"));
        }
Ejemplo n.º 24
0
        public IActionResult OnPost()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            if (!_auth)
            {
                return(Unauthorized());
            }

            var viewingId = Int32.Parse(Request.Form["viewingId"].ToString());
            var seats     = Request.Form["seats"].ToArray();

            List <string> takenSeats;
            Viewing       viewing;

            using (var db = new LiteDatabase(@"movieReservation.db")) {
                var col = db.GetCollection <Models.Viewing>("viewings");
                viewing            = col.FindOne(x => x.Id == viewingId);
                takenSeats         = seats.Concat(viewing.SeatsTaken).ToList();
                viewing.SeatsTaken = takenSeats;

                col.Update(viewing);
            }

            var reservation = new Models.Reservation {
                Name            = _auth.User.Email,
                Seats           = takenSeats,
                Time            = viewing.Time,
                Price           = viewing.Movie.Price,
                UserId          = _auth.User.Id,
                ReservationTime = DateTime.Now.Date,
            };

            using (var db = new LiteDatabase(@"movieReservation.db")) {
                var col = db.GetCollection <Models.Reservation>("reservations");
                col.Insert(reservation);
            }

            return(RedirectToPage("Index"));
        }
Ejemplo n.º 25
0
        public ActionResult Create(Models.Reservation model)
        {
            if (ModelState.IsValid)
            {
                if (!reservationService.ExistsReservation(model.ShowId, model.SeatId))
                {
                    var dbModel = new Domain.Reservation();
                    dbModel.InjectFrom(model);
                    reservationService.AddReservation(dbModel /*, dbModel1*/);
                    TempData["message"] = string.Format("{0} has been saved", model.ShowName);
                }
                else
                {
                    ModelState.AddModelError("SeatId", "This seat is already booked !");
                    ModelState.AddModelError("ShowId", "This show is already booked !");

                    //Seat
                    var seats    = seatRepository.GetAll();
                    var seatList = seats.Select(s => new SelectListItem()
                    {
                        Value = s.Id.ToString(),
                        Text  = s.SeatNo.ToString()
                    }).ToList();

                    //Show

                    var shows    = showRepository.GetAll();
                    var showList = shows.Select(s => new SelectListItem()
                    {
                        Value = s.Id.ToString(),
                        Text  = s.Film.Name
                    }).ToList();

                    ViewBag.Seats = seatList;
                    ViewBag.Shows = showList;
                    return(View(model));
                }

                return(RedirectToAction("Index"));
            }

            return(View(model));
        }
        public ActionResult SubmitReservation()
        {
            if (Session["accessLevel"] != null && (int)Session["accessLevel"] == 2)
            {
                Models.Reservation          reservation = ((Models.ReservationSearchData)TempData["Model"]).ToEntity();
                System.Net.Mail.MailMessage mail;

                using (Models.ReserveItEntities db = new Models.ReserveItEntities())
                {
                    Models.Room roomDetails = db.Rooms.AsNoTracking().Where(r => r.RoomID == reservation.RoomID).First();
                    reservation.UserID = (int)Session["userID"];

                    db.Reservations.Add(reservation);
                    db.SaveChanges();

                    mail = new System.Net.Mail.MailMessage(
                        "*****@*****.**",
                        (string)Session["email"],
                        "Reservation Details for #" + reservation.ReservationID,
                        "");

                    mail.Body = "<h1>Thank you for staying with us</h1>We hope you enjoy your stay. We try our utmost to ensure you have a comfortable and enjoyable experience.<br/><br/><h3>Find your Reservation Details below</h3>Reservation #: " + reservation.ReservationID +
                                "<br/>Hotel Location: " + roomDetails.Hotel.StreetAddress + ", " + roomDetails.Hotel.CityAddress + ", " + roomDetails.Hotel.StateAddress + "<br/>Room #: " + roomDetails.RoomNumber + "<br />Check In: " + reservation.CheckIn.ToShortDateString() +
                                "<br/>Check Out: " + reservation.CheckOut.ToShortDateString() + "<br/>Direct Phone #: " + roomDetails.Hotel.Phone;
                    mail.IsBodyHtml = true;
                }

                using (System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient())
                {
                    client.Credentials = new System.Net.NetworkCredential("*****@*****.**", "Intelligence94");
                    client.Host        = "smtp.gmail.com";
                    client.Port        = 587;
                    client.EnableSsl   = true;
                    client.Send(mail);
                }
            }

            TempData.Clear();

            return(RedirectToAction("Index", "Home"));
        }
Ejemplo n.º 27
0
        public ActionResult Index(DateTime rentalStartDate, DateTime rentalEndDate, int boardGameId, string boardGameName, int count, string discountCode, string rentalCostPerDay, string imagePath)
        {
            decimal totalCost = reservationService.CaculateTotalCostByBoardGameDiscountCode(discountCode, boardGameId, rentalStartDate, rentalEndDate, decimal.Parse(rentalCostPerDay));

            Session["TotalCost"] = totalCost; //brzydka lata

            DAL.Models.User userFromSession = userService.GetById((int)Session["UserId"]);
            Models.User     user            = new Models.User
            {
                UserId          = userFromSession.UserId,
                FirstName       = userFromSession.FirstName,
                LastName        = userFromSession.LastName,
                Email           = userFromSession.Email,
                PhoneNumber     = userFromSession.PhoneNumber,
                Street          = userFromSession.Street,
                HouseNumber     = userFromSession.HouseNumber,
                ApartmentNumber = userFromSession.ApartmentNumber,
                PostalCode      = userFromSession.PostalCode,
                City            = userFromSession.City
            };

            ViewBag.ImagePath = imagePath;
            Models.Reservation reservation = new Models.Reservation
            {
                RentalStartDate      = rentalStartDate,
                RentalEndDate        = rentalEndDate,
                BoardGameId          = boardGameId,
                Count                = count,
                User                 = user,
                TotalCost            = totalCost,
                BoardGameName        = boardGameName,
                BoardGameIsAvailable = boardGamesService.IsAvailable(boardGameId),
                ImagePath            = imagePath
            };
            return(View(reservation));
        }
        public MesReservations()
        {
            InitializeComponent();
            Title = "MES RESERVATIONS";
            List <Models.Reservation> lesReservations = new List <Models.Reservation>();

            lesReservations = Database.MyCovoit.getLesReservations();


            ScrollView scroll = new ScrollView();

            StackLayout stackLayout = new StackLayout();

            for (int i = 0; i < lesReservations.Count; i++)
            {
                Models.Reservation uneReservation = lesReservations[i];
                StackLayout        stackCard      = new StackLayout();

                Frame Card = new Frame
                {
                    Margin          = new Thickness(40, 20, 40, 0),
                    BackgroundColor = Color.FromHex("#27ae60"),
                    CornerRadius    = 10,
                    HasShadow       = true
                };

                StackLayout stakLabel = new StackLayout
                {
                    Padding = new Thickness(15, 0, 15, 0),
                };

                Label labelTest = new Label
                {
                    TextColor = Color.White,
                    Text      = "🚘 Montée : " + uneReservation.getMonte().ToString() + "\n" +
                                "🚩 Descente : " + uneReservation.getDescente() + "\n" +
                                "💰 Prix : " + uneReservation.getPrix().ToString() + "€" + "\n" +
                                "🧑 Conducteur : " + uneReservation.getConducteur().getPrenom() + " " + uneReservation.getConducteur().getNom(),
                    FontSize = 20
                };

                // Your label tap event
                var tapInfos = new TapGestureRecognizer();
                tapInfos.Tapped += (s, e) =>
                {
                    //ACTION A EFFECTUER QUAND ON CLIQUE SUR LES INFOS DU TRAJET
                    detailReservation = uneReservation;
                    Navigation.PushAsync(new DetailReservation());
                };
                labelTest.GestureRecognizers.Add(tapInfos);

                stakLabel.Children.Add(labelTest);

                stackCard.Children.Add(stakLabel);
                //stackCard.Children.Add(boutonStakLayout);

                Card.Content = stackCard;

                stackLayout.Children.Add(Card);
            }

            scroll.Content = stackLayout;
            Content        = scroll;
        }
Ejemplo n.º 29
0
 public ReservationController()
 {
     this.reservation = new Models.Reservation();
 }
Ejemplo n.º 30
0
        /**
         * Controller to handle selection of a table row
         */

        public void handleTableRowSelection()
        {
            try {
                Cursor.Current = Cursors.WaitCursor;

                this.handleResetButton();

                var selectedRow = this.view.ReservationsTable.DataGrid.SelectedRows.Count > 0
                    ? this.view.ReservationsTable.DataGrid.SelectedRows[0]
                    : null;

                if (selectedRow != null)
                {
                    int id = (int)selectedRow.Cells[0].Value;

                    this.reservations.ForEach(async(item) => {
                        if (item.Id == id)
                        {
                            this.selectedReservation = item;
                            this.view.SelectedReservationLabel.Text = this.selectedReservation.Id.ToString();

                            // Populate list box with medicaments
                            this.view.MedicamentsListBox.Items.Clear();
                            this.view.MedicamentsListBox.Refresh();

                            if (this.medicaments != null && this.medicaments.Count > 0)
                            {
                                this.medicaments.ForEach((medicament) => {
                                    this.view.MedicamentsListBox.Items.Add(medicament);
                                });
                            }

                            // Read prescription for selected reservation
                            this.selectedPrescription = await prescriptionModel.readPrescriptionForReservation(
                                this.selectedReservation.Id
                                );

                            // If there is an existing prescription, show its content
                            if (this.selectedPrescription != null)
                            {
                                List <Models.PrescriptionMedicament> pm = await prescriptionMedicamentModel.readMedicamentsForPrescription(
                                    this.selectedPrescription.Id
                                    );
                                this.selectedPrescriptionMedicaments = pm;

                                this.view.DescriptionTxtBox.ReadOnly = true;
                                this.view.MedicamentsListBox.Enabled = false;
                                this.view.SubmitBtn.Enabled          = false;
                                this.view.DescriptionTxtBox.Text     = this.selectedPrescription.Description;

                                for (int i = 0; i < this.view.MedicamentsListBox.Items.Count; i += 1)
                                {
                                    Models.Medicament m = (Models.Medicament) this.view.MedicamentsListBox.Items[i];

                                    pm.ForEach((pmItem) => {
                                        if (pmItem.Medicament == m.Id)
                                        {
                                            this.view.MedicamentsListBox.SetSelected(i, true);
                                        }
                                    });
                                }
                            }
                        }
                    });
                }

                Cursor.Current = Cursors.Arrow;
            } catch (Exception e) {
                string caption = "Problem në lexim";
                MessageBox.Show(e.Message, caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }