Example #1
0
 public AddModel(VehicleStore vehicleStore, CustomerStore customerStore)
 {
     VehicleStore  = vehicleStore;
     CustomerStore = customerStore;
     Customers     = new List <Customer>();
     Customers     = CustomerStore.GetCustomers();
 }
Example #2
0
        public Insurance GetPrice(Guid idCustomer, Guid idVehicle)
        {
            double   IncreaseByAge1 = 0.30;
            double   IncreaseByAge2 = 0.10;
            double   IncreaseByCity = 0.10;
            double   IncreaseByCar  = 0.05;
            Vehicle  Vehicle        = VehicleStore.GetVehiclesById(idVehicle);
            Customer Customer       = CustomerStore.GetCustomerById(idCustomer);

            Insurance            = new Insurance();
            Insurance.CustomerId = idCustomer;
            Insurance.VehicleId  = idVehicle;
            Insurance.City       = Customer.City;
            int Age = DateTime.Today.AddTicks(-Customer.BornDate.Ticks).Year - 1;

            if (Customer.City == "Medellín")
            {
                Insurance.IncreaseByCity = Insurance.Baseprice * IncreaseByCity;
            }
            if (Vehicle.Year < (DateTime.Today.Year - 10))
            {
                Insurance.IncreaseByCar = Insurance.Baseprice * IncreaseByCar;
            }
            if (Age >= 16 && Age < 25)
            {
                Insurance.IncreaseByAge = Insurance.Baseprice * IncreaseByAge1;
            }
            else if (Age >= 25 && Age < 40)
            {
                Insurance.IncreaseByAge = Insurance.Baseprice * IncreaseByAge2;
            }
            Insurance.Total = Insurance.Baseprice + Insurance.IncreaseByAge + Insurance.IncreaseByCar + Insurance.IncreaseByCity;
            return(Insurance);
        }
        public IActionResult OnPostDelete(Guid id)
        {
            var idCliente = VehicleStore.GetVehicleById(id).ClientId;

            VehicleStore.DeleteVehicle(id);
            return(RedirectToPage("./Index", new { id = idCliente }));
        }
        public void OnPostDelete(Guid id)
        {
            Vehicle cVehicle = VehicleStore.GetVehiclesById(id);

            CustomerId = cVehicle.CustomerId;
            VehicleStore.DeleteVehicle(id);
        }
Example #5
0
 public void OnGet(Guid customerid)
 {
     CustomerId = customerid;
     Vehicles   = VehicleStore.GetVehiclesByCustomer(customerid);
     Customer   = CustomerStore.GetCustomerById(customerid);
     Age        = DateTime.Today.AddTicks(-Customer.BornDate.Ticks).Year - 1;
     MaxYear    = DateTime.Today.Year + 1;
 }
Example #6
0
 public IActionResult Delete(Guid id)
 {
     Vehicle = VehicleStore.GetVehiclesById(id);
     //VehicleStore.DeleteVehicle(id);
     CustomerId = Vehicle.CustomerId;
     Vehicles   = VehicleStore.GetVehiclesByCustomer(CustomerId);
     return(RedirectToPage());
 }
Example #7
0
 public AddModel(VehicleStore vehicleStore, CustomerStore customerStore, InsuranceStore insuranceStore,
                 InsurancesRules insurancesRules)
 {
     VehicleStore    = vehicleStore;
     CustomerStore   = customerStore;
     InsuranceStore  = insuranceStore;
     InsurancesRules = insurancesRules;
 }
 public IActionResult OnPostAsync()
 {
     if (!ModelState.IsValid)
     {
         return(Page());
     }
     VehicleStore.EditVehicle(Vehicle);
     return(RedirectToPage("./Index", new { id = Vehicle.ClientId }));
 }
Example #9
0
 public IndexModel(VehicleStore vehicleStore, CustomerStore customerStore, InsuranceStore insuranceStore)
 {
     VehicleStore   = vehicleStore;
     CustomerStore  = customerStore;
     InsuranceStore = insuranceStore;
     Vehicles       = VehicleStore.GetVehicles();
     Customers      = CustomerStore.GetCustomers();
     Insurances     = InsuranceStore.GetInsurances();
 }
        public IActionResult OnPostAsync()
        {
            if (!ModelState.IsValid) //Hace la validacion inversa... si no es valido el modelo
            {
                return(Page());      //Permanece en la pagina
            }

            VehicleStore.AddVehicle(Vehicle);
            return(RedirectToPage("../Customers/View", new { customerid = Vehicle.CustomerId }));
        }
Example #11
0
 public void OnGet(Guid vehicleid)
 {
     Vehicle    = VehicleStore.GetVehiclesById(vehicleid);
     Customer   = CustomerStore.GetCustomerById(Vehicle.CustomerId);
     idCustomer = Customer.Id;
     idVehicle  = Vehicle.Id;
     City       = Customer.City;
     Insurance  = InsurancesRules.GetPrice(idCustomer, idVehicle);
     Age        = DateTime.Today.AddTicks(-Customer.BornDate.Ticks).Year - 1;
 }
Example #12
0
        public IActionResult OnPostAsync()
        {
            if (!ModelState.IsValid) //Hace la validacion inversa... si no es valido el modelo
            {
                return(Page());      //Permanece en la pagina
            }

            VehicleStore.AddVehicle(Vehicle);
            return(Page());
        }
Example #13
0
        public void UpdateVehicle()
        {
            PhysicsEntity ve = (Vehicle as PhysicsEntity);
            int           id = CurrentVehiclePacketID;

            CurrentVehiclePacketID = (CurrentVehiclePacketID + 1) % PACKET_CAP;
            VehicleMarks[id]       = new VehicleStore()
            {
                Pos = ve.GetPosition(), Vel = ve.GetVelocity(), AVel = ve.GetAngularVelocity(), Quat = ve.GetOrientation(), Time = CurrentRemoteGTT
            };
            TheClient.Network.SendPacket(new MyVehiclePacketOut(id));
        }
Example #14
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, VehicleStore store)
        {
            store.Initialize();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseCors();
            app.UseRouting();
            app.UseEndpoints(endpoints => { endpoints.MapControllers(); });
        }
Example #15
0
        public IndexModel(VehicleStore vehicleStore, CustomerStore customerStore)
        {
            VehicleStore  = vehicleStore;
            CustomerStore = customerStore;


            Customer  = new Customer();
            Vehicle   = new Vehicle();
            Insurance = new Insurance();

            Customers = new List <Customer>();
            Vehicles  = new List <Vehicle>();

            Vehicles  = VehicleStore.GetVehicles();
            Customers = CustomerStore.GetCustomers();
        }
Example #16
0
        public IActionResult OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }
            double increase;

            //Add
            Vehicle.CustomerId = CustomerId;
            var customer = Customers.FirstOrDefault(x => x.Id == CustomerId);

            increase = Vehicle.Insurance.GetIncrease(customer.Age, customer.City, Vehicle.Year);
            Vehicle.Insurance.Increase = increase;
            VehicleStore.AddVehicle(Vehicle);
            return(RedirectToPage("./Index", "CustomerId", new { CustomerId = CustomerId }));
        }
Example #17
0
        public IActionResult OnGet(Guid id)
        {
            var vehicle = VehicleStore.GetVehicleById(id);
            var client  = ClientStore.GetClientById(vehicle.ClientId);

            Id = vehicle.ClientId;
            double precioBase = 1000000.0;

            if (DateTime.Now.Year - client.FechaNacimiento.Year < 16)
            {
                Message = "No se puede vender seguros a clientes menores de 16 años.";
                return(Page());
            }
            if (client.CiudadResidencia.CompareTo("Medellin") == 0)
            {
                precioBase += 100000;
            }
            var age = Services.CalculateAge.Calcule(client.FechaNacimiento);

            if (age >= 16 && age < 25)
            {
                precioBase += 300000;
            }
            else if (age >= 25 && age <= 40)
            {
                precioBase += 100000;
            }
            if (DateTime.Now.Year - vehicle.Anio > 10)
            {
                precioBase += 50000;
            }
            vehicle.ValorSeguro = precioBase;
            VehicleStore.EditVehicle(vehicle);
            Message = "El valor final del seguro es de " + precioBase;
            return(RedirectToPage("./Index", new { id = client.Id }));
        }
Example #18
0
 public IActionResult OnPostDelete(Guid id)
 {
     VehicleStore.DeleteVehicle(id);
     return(RedirectToPage());
 }
Example #19
0
 public InsurancesRules(VehicleStore vehicleStore, CustomerStore customerStore, InsuranceStore insuranceStore)
 {
     VehicleStore   = vehicleStore;
     CustomerStore  = customerStore;
     InsuranceStore = insuranceStore;
 }
 public IndexModel(VehicleStore vehicleStore)
 {
     VehiclesByCostumerId = new List <Vehicle>();
     VehicleStore         = vehicleStore;
     Vehicles             = VehicleStore.GetVehicles();
 }
Example #21
0
 public AddModel(VehicleStore vehicleStore)
 {
     VehicleStore = vehicleStore;
 }
Example #22
0
 public BuyInsuranceModel(VehicleStore vehicleStore, ClientStore clientStore)
 {
     VehicleStore = vehicleStore;
     ClientStore  = clientStore;
 }
 public IndexModel(VehicleStore vehicleStore)
 {
     VehicleStore = vehicleStore;
     Vehicles     = VehicleStore.GetVehicles();
 }
 public AddModel(CustomerStore customerStore, VehicleStore vehicleStore)
 {
     VehicleStore  = vehicleStore;
     CustomerStore = customerStore;
 }
Example #25
0
 public EditModel(VehicleStore vehicleStore)
 {
     VehicleStore = vehicleStore;
 }
Example #26
0
 public IActionResult OnPostDelete(Guid vehicleid)
 {
     VehicleStore.DeleteVehicle(vehicleid);
     return(RedirectToPage("../Customers/Index"));
 }
Example #27
0
 public void OnGet(Guid id)
 {
     Vehicle = VehicleStore.GetVehicleById(id);
 }
 public void OnGet(Guid customerId)
 {
     Vehicles = VehicleStore.GetVehiclesByCustomer(customerId);
 }
 public _IndexVehiclePartialModel(VehicleStore vehicleStore)
 {
     VehicleStore = vehicleStore;
 }
Example #30
0
 public ViewModel(VehicleStore vehicleStore, CustomerStore customerStore)
 {
     VehicleStore  = vehicleStore;
     CustomerStore = customerStore;
 }