Ejemplo n.º 1
0
        public virtual Rental AddRental(Video video)
        {
            var rental = new Rental(this, video);

            Rentals.Add(rental);
            return(rental);
        }
Ejemplo n.º 2
0
        public Rental CreateRental(
            User user)
        {
            Rental r = Rentals.Create();

            r.User = user;
            Rentals.Add(r);
            SaveChanges();
            return(r);
        }
Ejemplo n.º 3
0
        public Rental CreateBasket()
        {
            var basket = Model.Rentals.Create();

            basket.User = this;
            Rentals.Add(basket);
            Model.Rentals.Add(basket);
            Model.SaveChanges();
            return(basket);
        }
Ejemplo n.º 4
0
        private void add_Click(object sender, EventArgs e)
        {
            if (!Rentals.Contains(VideoSelected))
            {
                Rentals.Add(VideoSelected);
            }

            rentalList.DataSource = Rentals;
            totalAmount.DataBindings.Clear();
            totalAmount.DataBindings.Add("Text", this, nameof(this.totalAmount));
        }
Ejemplo n.º 5
0
        private void RefreshRentals()
        {
            Rentals.Clear();

            foreach (var item in _rentals)
            {
                var rental = new RentalViewModel(item);

                switch (_currentFilter)
                {
                case Filter.User:
                    if (rental.User.FullName.Equals(_currentUser.FullName))
                    {
                        Rentals.Add(rental);
                    }

                    CurrentDateOfRental = null;
                    CurrentDueDate      = null;
                    break;

                case Filter.DueDate:
                    if (rental.DueDate.Equals(_currentDueDate))
                    {
                        Rentals.Add(rental);
                    }

                    CurrentDateOfRental = null;
                    CurrentUser         = null;
                    break;

                case Filter.DateOfRental:
                    if (rental.DateOfRental.Equals(_currentDateOfRental))
                    {
                        Rentals.Add(rental);
                    }

                    CurrentDueDate = null;
                    CurrentUser    = null;
                    break;

                default:
                    Rentals.Add(rental);
                    CurrentDateOfRental = null;
                    CurrentDueDate      = null;
                    CurrentUser         = null;
                    break;
                }
            }
        }
Ejemplo n.º 6
0
        public void AddRental(Station OriginStation, Scooter scooter, User User)
        {
            DateTime?EndDate   = null;
            Decimal  Price     = 0;
            DateTime StartDate = DateTime.Now;

            Rental rental = new Rental(EndDate, Price, StartDate, OriginStation, scooter, User);

            Rentals.Add(rental);

            scooter.AddRental(rental); //no se si hay que ponerlo
            OriginStation.AddOriginRental(rental);
            OriginStation.DeleteFirstScooter(scooter);
            // Scooter.StateInUse();
        }
Ejemplo n.º 7
0
 public bool CreateRental(Rental rental, string userId)
 {
     try
     {
         if (!Rentals.Items.Any(x => x.Name == rental.Name.Trim()))
         {
             rental.Name        = rental.Name.Trim();
             rental.Shortname   = rental.Shortname.Trim();
             rental.UserCreated = userId;
             rental.CompanyId   = Companies.GetCompany.Id;
             Rentals.Add(rental);
             return(true);
         }
     }
     catch (Exception e)
     {
     }
     return(false);
 }
        private void BtnNewRental_Click(object sender, RoutedEventArgs e)
        {
            if (lstResidences.SelectedItem != null)
            {
                Residence residence = (Residence)lstResidences.SelectedItem;

                if (!residence.IsRentable)
                {
                    MessageBox.Show($"Verblijf {residence} momenteel niet verhuurbaar...");
                    return;
                }

                WinRental rentalWindow = new WinRental(residence, rentals, tenants);
                rentalWindow.ShowDialog();
                if (rentalWindow.Rental != null)
                {
                    rentals.Add(rentalWindow.Rental);
                }
                UpdateRentals();
            }
        }
Ejemplo n.º 9
0
 public void AddVideo(IRentable newVid)
 {
     Rentals.Add(newVid);
 }
Ejemplo n.º 10
0
        public void InitialDbData()
        {
            if (!Cars.Any())
            {
                List <Vehicle> cars = new List <Vehicle>()
                {
                    new Car()
                    {
                        CarId = Guid.Parse("7295a624-dea8-479c-b920-a3254f92af77"), CurrentDistance = 20.3, RegistrationNumber = "KRA2436", Status = Status.wolny, TotalDistance = 15034.5, XPosition = 2.4, YPosition = 5.2
                    },
                    new Car()
                    {
                        CarId = Guid.Parse("6291ffd4-cb73-4c37-aa9a-1591247f554d"), CurrentDistance = 13.7, RegistrationNumber = "KOL0201", Status = Status.wypożyczony, TotalDistance = 20134.5, XPosition = 1.4, YPosition = -2.2
                    },
                    new Car()
                    {
                        CarId = Guid.Parse("7fb934b4-dae2-4659-a9ee-d5af7af36f40"), CurrentDistance = 20.3, RegistrationNumber = "KRA2436", Status = Status.wolny, TotalDistance = 15034.5, XPosition = 2.4, YPosition = 5.2
                    }
                };
                foreach (Car item in cars)
                {
                    Cars.Add(item);
                    var carReadModel = new CarViewModel()
                    {
                        CarId              = item.CarId,
                        CurrentDistance    = item.CurrentDistance,
                        RegistrationNumber = item.RegistrationNumber,
                        Status             = item.Status,
                        TotalDistance      = item.TotalDistance,
                        XPosition          = item.XPosition,
                        YPosition          = item.YPosition
                    };
                    CarViewModels.Add(carReadModel);
                }
            }

            if (!Drivers.Any())
            {
                Driver driver = new Driver("42222/12/01118", "Jan", "Kowalski");
                driver.DriverId = Guid.Parse("0871afd6-dae6-45f2-b9cf-8f91f184d6af");

                Drivers.Add(driver);

                DriverViewModel driverViewModel = new DriverViewModel()
                {
                    DriverId      = driver.DriverId,
                    FirstName     = driver.FirstName,
                    LastName      = driver.LastName,
                    LicenceNumber = driver.LicenceNumber
                };

                DriverViewModels.Add(driverViewModel);
            }

            if (!Rentals.Any())
            {
                Rental rental = new Rental()
                {
                    RentalId = Guid.Parse("1c3444e1-e09c-48a1-9cf2-db713731b5b1"),
                    CarId    = Guid.Parse("6291ffd4-cb73-4c37-aa9a-1591247f554d"),
                    Started  = DateTime.ParseExact("21/05/2020 07:25:47", "dd/MM/yyyy hh:mm:ss", CultureInfo.InvariantCulture),
                    DriverId = Guid.Parse("0871afd6-dae6-45f2-b9cf-8f91f184d6af")
                };

                Rentals.Add(rental);

                if (Cars.Any())
                {
                    var carToUpdate = Cars.FirstOrDefault(x => x.CarId == rental.CarId);
                    carToUpdate.ChangeStatus();
                }

                RentalReadModel rentalReadModel = new RentalReadModel()
                {
                    RentalId           = rental.RentalId,
                    RegistrationNumber = "KOL0201",
                    CarId          = rental.CarId,
                    DriverId       = rental.DriverId,
                    Driver         = "Jan Kowalski",
                    Created        = rental.Started,
                    StartXPosition = 1.4,
                    StartYPosition = -2.2
                };

                RentalReadModels.Add(rentalReadModel);
            }

            this.SaveChanges();
        }
Ejemplo n.º 11
0
 public void AddRental(Rental rental)
 {
     Rentals.Add(rental);
 }
Ejemplo n.º 12
0
 public virtual void AddRental(Rental rental)
 {
     rental.Customer = this;
     Rentals.Add(rental);
 }
Ejemplo n.º 13
0
 public void AddRental(Rental arg)
 {
     Rentals.Add(arg);
 }