Ejemplo n.º 1
0
        public List <SailingBoat> GetAvailableBoats(DateTime reservationDate, TimeSpan duration)
        {
            var boats          = _boatService.GetAllBoats();
            var availableBoats = new List <SailingBoat>();

            foreach (var boat in boats)
            {
                var available = true;

                if ((BoatState)boat.Status != BoatState.InService)
                {
                    foreach (var reserv in boat.SailingReservations)
                    {
                        if (!DateChecker.AvailableOn(reserv.Date, reserv.Duration, reservationDate, duration))
                        {
                            available = false;
                        }
                    }

                    if (available)
                    {
                        availableBoats.Add(boat);
                    }
                }
            }

            return(availableBoats);
        }
Ejemplo n.º 2
0
        // Set data for the boat view.
        public void SetBoatData(IBoatService boatService)
        {
            Items.Clear();
            var boats = boatService.GetAllBoats()
                        .Select(r => new BoatTypeViewModel
            {
                Id = r.Id,
                PossiblePassengers = r.BoatType.PossiblePassengers,
                RequiredLevel      = r.BoatType.RequiredLevel,
                Name             = r.BoatType.Name,
                HasCommanderSeat = r.BoatType.HasCommanderSeat.ToString(),
                Status           = r.Status.ToString()
            }).ToList();

            foreach (var boat in boats)
            {
                var status = (BoatState)Enum.Parse(typeof(BoatState), boat.Status);
                if (status == BoatState.InUse)
                {
                    boat.Status = "In gebruik";
                }
                if (status == BoatState.InStock)
                {
                    boat.Status = "In magazijn";
                }
                if (status == BoatState.InService)
                {
                    boat.Status = "Schade";
                }
                if (boat.HasCommanderSeat.Equals("True"))
                {
                    boat.HasCommanderSeat = "Ja";
                }
                if (boat.HasCommanderSeat.Equals("False"))
                {
                    boat.HasCommanderSeat = "Nee";
                }
                Items.Add(boat);
            }
        }