Esempio n. 1
0
 private static void AddStations(IDAL dal)
 {
     EcoScooter.Entities.EcoScooter ecoScooter = dal.GetAll <EcoScooter.Entities.EcoScooter>().First();
     ecoScooter.Stations.Add(new Station("Camino de Vera s/n. 46022 Valencia", "UPV", 39.482369, -0.343578));
     ecoScooter.Stations.Add(new Station("Avda Aragón 33. 46010 Valencia", "Aragón", 39.4698, -0.3774));
     dal.Commit();
 }
Esempio n. 2
0
        void addEcoScooter()
        {
            Console.WriteLine();
            Console.WriteLine("ADDING ECOSCOOTER...");

            try
            {
                // Administrator
                // public Employee(DateTime birthDate, String dni, String email, String name, int telephon, String iban, int pin, String position, Decimal salary )
                Employee e = new Employee(DateTime.Parse("19/10/2000"), "12341234A", "*****@*****.**", "Rodolfo Valentino", 96123123, "ES651234567890", 1234, "Administrator", 3000);

                EcoScooter.Entities.EcoScooter ecoscooter;
                // public EcoScooter(Double discountYounger, Double fare, Double maxSpeed, Employee firstEmpl)
                ecoscooter = new EcoScooter.Entities.EcoScooter(10, 0.015, 30, e);

                service.addEcoScooter(ecoscooter);
                Console.WriteLine(ecoScooterToString(service.getEcoScooter()));

                Console.WriteLine("   Employee list:");
                foreach (Employee emp in ecoscooter.Employees)
                {
                    Console.WriteLine(employeeToString(emp));
                }
            }
            catch (Exception e)
            {
                printError(e);
            }
        }
Esempio n. 3
0
        private static void AddEcoScooter(IDAL dal)
        {
            Employee employee = new Employee(new Date​Time(1995, 07, 27), "12345678Z", "*****@*****.**", "First Employe", 600123456, "ES6621000418401234567891", 123, "Maintenance", 1200);

            EcoScooter.Entities.EcoScooter ecoScooter = new EcoScooter.Entities.EcoScooter(10, 15, 30, employee);
            ecoScooter.People.Add(employee);
            dal.Insert(ecoScooter);
            dal.Commit();
        }
 public void addEcoScooter(EcoScooter.Entities.EcoScooter ecoScooter)
 {
     //if (dal.GetById<EcoScooter.Entities.EcoScooter>(ecoScooter.Id) == null)
     //{
     dal.Insert <EcoScooter.Entities.EcoScooter>(ecoScooter);
     dal.Commit();
     // }
     // else throw new ServiceException("Este EcoScooter ya existe.");
 }
Esempio n. 5
0
        private static void AddScooters(IDAL dal)
        {
            EcoScooter.Entities.EcoScooter ecoScooter = dal.GetAll <EcoScooter.Entities.EcoScooter>().First();
            Scooter scooter1 = new Scooter(new Date​Time(2019, 01, 01), ScooterState.available);

            scooter1.Station = ecoScooter.Stations.First();
            ecoScooter.Scooters.Add(scooter1);
            ecoScooter.Scooters.Add(new Scooter(new Date​Time(2019, 01, 01), ScooterState.inMaintenance));
            dal.Commit();
        }
Esempio n. 6
0
        private static void AddUsers(IDAL dal)
        {
            EcoScooter.Entities.EcoScooter ecoScooter = dal.GetAll <EcoScooter.Entities.EcoScooter>().First();
            User user1 = new User(new Date​Time(2000, 12, 01), "1234", "*****@*****.**", "First User", 605123456, 345, new Date​Time(2022, 12, 31), "firstUSer", 12345678, "1234");

            User user2 = new User(new Date​Time(1977, 12, 01), "12345680Q", "*****@*****.**", "Second User", 605123457, 543, new Date​Time(2023, 12, 31), "secondtUSer", 87654321, "4321");

            dal.Insert(user1);
            dal.Insert(user2);
            ecoScooter.People.Add(user1);
            ecoScooter.People.Add(user2);
            dal.Commit();
        }
Esempio n. 7
0
        private static void AddRentals(IDAL dal)
        {
            EcoScooter.Entities.EcoScooter ecoScooter = dal.GetAll <EcoScooter.Entities.EcoScooter>().First();

            var    users  = ecoScooter.People.OfType <User>();
            Rental rental = new Rental(new Date​Time(2019, 10, 14, 16, 55, 56), 30, new Date​Time(2019, 10, 14, 16, 54, 56),
                                       ecoScooter.Stations.First(), ecoScooter.Scooters.First(), users.First());

            rental.DestinationStation = ecoScooter.Stations.Last();
            dal.Insert(rental);
            dal.Insert(new Rental(null, 0, new Date​Time(2019, 11, 06, 12, 00, 00),
                                  ecoScooter.Stations.First(), ecoScooter.Scooters.First(), users.First()));
            dal.Commit();
        }
Esempio n. 8
0
        static void Main(string[] args)
        {
            Employee e;

            e = new Employee(DateTime.Parse("19/10/2000"), "20123123A", "*****@*****.**", "Rodolfo Valentino", 96123123, "ES651234567890", 1234, "Vertical", 3000);
            Console.WriteLine("Nombre del empleado: " + e.Name);

            EcoScooter.Entities.EcoScooter ecoScooter;
            ecoScooter = new EcoScooter.Entities.EcoScooter(5, 10, 30);

            ecoScooter.Employees.Add(e);
            Console.WriteLine("Nombre del primer empleado: " + ecoScooter.Employees.First().Name);
            Console.ReadLine();
        }
Esempio n. 9
0
 public void ConstructorInitializesPropsAndEmployees()
 {
     try
     {
         EcoScooter.Entities.EcoScooter ecoScooter = new EcoScooter.Entities.EcoScooter(EXPECTED_DISCOUNT, EXPECTED_FARE, EXPECTED_SPEED, new Employee());
         int numEmployees = ecoScooter.Employees.Count;
         Assert.AreEqual(EXPECTED_DISCOUNT, ecoScooter.DiscountYounger, "DiscountYounger no properly initialized. Check params order and assigment");
         Assert.AreEqual(EXPECTED_FARE, ecoScooter.Fare, "Fare no properly initialized.Check the params order");
         Assert.AreEqual(EXPECTED_SPEED, ecoScooter.MaxSpeed, "MaxSpeed no properly initialized.Check params order and assigment");
         Assert.AreEqual(EXPECTED_NUM_EXPLOYEES, numEmployees, "The employee is not added to the collection Employees in the constructor with params");
     }
     catch (System.NullReferenceException)
     {
         Assert.Fail("Collection of Employee no properly initialized.\n Patch the problem adding:  Employee = new List<Employee>();");
     }
 }
Esempio n. 10
0
        private void createSampleDB(IDAL dal)
        {
            // Remove all data from DB
            dal.RemoveAllData();

            // Populate the database with data
            Employee e = new Employee(DateTime.Parse("19/10/2000"), "20123123A", "*****@*****.**", "Rodolfo Valentino", 96123123, "ES651234567890", 1234, "Vertical", 3000);

            dal.Insert <Employee>(e);
            dal.Commit();

            EcoScooter.Entities.EcoScooter ecoscooter;
            ecoscooter = new EcoScooter.Entities.EcoScooter(5, 10, 30, e);
            dal.Insert <EcoScooter.Entities.EcoScooter>(ecoscooter);
            dal.Commit();

            // ... more objects ...
        }
Esempio n. 11
0
        public void UpdateRental(Station destinationStation, User loggedUser, Rental rental, EcoScooter ecoScooter)
        {
            this.DestinationStation = destinationStation;
            this.EndDate            = DateTime.Now;
            this.Price = ecoScooter.CalculatePrice((DateTime)this.EndDate, this.StartDate, loggedUser.getAge());

            if (loggedUser.getAge() <= 25)
            {
                this.Price = ecoScooter.CalculateDiscount(this.Price);
            }

            this.Scooter.StateAvailable(destinationStation);

            destinationStation.AddDestinationRental(rental);
            destinationStation.AddScooter(this.Scooter);
        }
Esempio n. 12
0
 public void ConstructorInitializesStations()
 {
     EcoScooter.Entities.EcoScooter ecoScooter = new EcoScooter.Entities.EcoScooter();
     Assert.IsNotNull(ecoScooter.Stations, "Collection of Station no properly initialized.\n Patch the problem adding:  Stations = new List<Station>();");
 }
Esempio n. 13
0
 public void ConstructorInitializesPeople()
 {
     EcoScooter.Entities.EcoScooter ecoScooter = new EcoScooter.Entities.EcoScooter();
     Assert.IsNotNull(ecoScooter.People, "Collection of Person no properly initialized.Patch the problem adding:  People = new List<Person>();");
 }
Esempio n. 14
0
 public void NoParamsConstructorInitializesScooters()
 {
     EcoScooter.Entities.EcoScooter ecoScooter = new EcoScooter.Entities.EcoScooter();
     Assert.IsNotNull(ecoScooter.Scooters, "Collection of Scooter no properly initialized.\n Patch the problem adding:  Scooters = new List<Scooter>();");
 }
Esempio n. 15
0
 public void NoParamsConstructorInitializesEmployees()
 {
     EcoScooter.Entities.EcoScooter ecoScooter = new EcoScooter.Entities.EcoScooter();
     Assert.IsNotNull(ecoScooter.Employees, "Collection of Employee no properly initialized.\n Patch the problem adding:  Employees = new List<Employee>();");
 }
Esempio n. 16
0
 String ecoScooterToString(EcoScooter.Entities.EcoScooter e)
 {
     return("   DiscountYounger: " + e.DiscountYounger + "  MaxSpeed: " + e.MaxSpeed + ", fare = " + e.Fare);
 }