Пример #1
0
        static void trenEnMarxa(object tren)
        {
            Tren myTren = (Tren)tren;

            for (int i = myTren.kmInicial; i <= 100; i = i + myTren.decrementacio)
            {
                if (i == myTren.kmEsperar)
                {
                    sem.Wait();
                }

                if ((i > myTren.kmEsperar) && (i < myTren.kmSortir))
                {
                    Console.WriteLine("\t\tTren " + myTren.numeroTren + " ({0})", i);
                }
                else if (i == myTren.kmSortir)
                {
                    sem.Release();
                }
                else
                {
                    Console.WriteLine("Tren " + myTren.numeroTren + " ({0})", i);
                }

                Thread.Sleep(myTren.tempsRetard);
            }
        }
Пример #2
0
        private void button4_Click(object sender, EventArgs e)
        {
            List <Tren> trenler = HelperTren.GetListTrens();

            foreach (var item in trenler)
            {
                if (item.trenAdi.ToLower().Contains(textBox1.Text.ToLower()))
                {
                    if (item.trenAdi == textBox1.Text)
                    {
                        MessageBox.Show("Böyle bir tren adı bulunmakta! Başka bir tren giriniz!");
                        this.Close();
                    }
                }
            }
            Tren t = new Tren();

            t.trenAdi      = textBox1.Text;
            t.koltukSayisi = 100;
            var f = HelperTren.Add(t);

            if (f.Item2)
            {
                MessageBox.Show("Treniniz Eklenmiştir");
            }
            else
            {
                MessageBox.Show("Eklenmede Hata Oluştu");
            }
            TrenleriDoldur();
        }
Пример #3
0
        public async Task <IActionResult> PutTren(int id, Tren tren)
        {
            if (id != tren.id)
            {
                return(BadRequest());
            }

            _context.Entry(tren).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TrenExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Пример #4
0
        public void RePoblarPedido_PedidoSeHaPobladoAnteriormente_CompletarCamposExtra()
        {
            //Arrange
            DateTime fechaActual = new DateTime(2020, 02, 14);
            Tren     tren        = new Tren(5, 80);

            _obtenedorEscala.Setup(x => x.ObtenerEscalaTiempo(It.IsAny <DateTime>(), It.IsAny <DateTime>())).Returns(EscalaTiempo.Hora);
            _obtenedorTipoEvento.Setup(x => x.ObtenerTipoEvento(It.IsAny <DateTime>(), It.IsAny <DateTime>())).Returns(TipoEvento.Futuro);
            _obtenedorDuracion.Setup(x => x.ObtenerDuracion(It.IsAny <DateTime>(), It.IsAny <DateTime>(), It.IsAny <EscalaTiempo>())).Returns(21);
            _calculador.Setup(x => x.CalcularCosto(It.IsAny <double>(), It.IsAny <int>(), It.IsAny <int>())).Returns(122.23);
            _calculador.Setup(x => x.CalcularFechaEntrega(It.IsAny <DateTime>(), It.IsAny <double>(), It.IsAny <EscalaTiempo>())).Returns(new DateTime(2020, 07, 21));

            IPedido pedido = new Pedido()
            {
                Origen           = "Tizimín",
                Destino          = "Mérida",
                Distancia        = 147,
                Empresa          = "DHL",
                NombreTransporte = "Tren",
                TipoTransporte   = TipoTransporte.Tren,
                FechaHora        = new DateTime(2020, 01, 01, 0, 1, 0)
            };

            //Act
            _pobladorPedido.RePoblarPedido(pedido, fechaActual, 2, tren);

            //Assert
            Assert.AreEqual(EscalaTiempo.Hora, pedido.EscalaTiempo);
            Assert.AreEqual(TipoEvento.Futuro, pedido.Tiempo);
            Assert.AreEqual(21, pedido.Duracion);
            Assert.AreEqual(122.23, pedido.Costo);
            Assert.AreEqual(new DateTime(2020, 07, 21), pedido.FechaEntrega);
        }
Пример #5
0
        public ITransporte ObtenerTransporte(string _cTransporte, DatosConfiguracion _entDatosConfig)
        {
            ITransporte      Transporte;
            MediosTransporte datosMedios;

            switch (_cTransporte)
            {
            case "Marítimo":
                datosMedios = _entDatosConfig.MediosTransporte.Where(w => w.Medio == "Marítimo").FirstOrDefault();
                Transporte  = new Barco(datosMedios.CostoPorKilometro, datosMedios.Velocidad);
                break;

            case "Terrestre":
                datosMedios = _entDatosConfig.MediosTransporte.Where(w => w.Medio == "Terrestre").FirstOrDefault();
                Transporte  = new Tren(datosMedios.CostoPorKilometro, datosMedios.Velocidad);
                break;

            case "Aéreo":
                datosMedios = _entDatosConfig.MediosTransporte.Where(w => w.Medio == "Aéreo").FirstOrDefault();
                Transporte  = new Avion(datosMedios.CostoPorKilometro, datosMedios.Velocidad);
                break;

            default:
                throw new Exception("No existe el transporte solicitado");
            }

            return(Transporte);
        }
Пример #6
0
        public List <EntidadBase> BuildObjects(List <Dictionary <string, object> > lstRows)
        {
            var lstResults = new List <EntidadBase>();

            foreach (var row in lstRows)
            {
                var Tren = new Tren
                {
                    CodTren     = GetIntValue(row, DB_COL_COD_TREN) + "",
                    Modelo      = GetStringValue(row, DB_COL_MODELO),
                    Matricula   = GetStringValue(row, DB_COL_MATRICULA),
                    Nombre      = GetStringValue(row, DB_COL_NOMBRE),
                    FechaCompra = GetStringValue(row, DB_COL_FECHA_COMPRA),
                    Costo       = GetDecimalValue(row, DB_COL_COSTO),
                    Descripcion = GetStringValue(row, DB_COL_DESCRIPCION),
                    Estado      = GetStringValue(row, DB_COL_ESTADO),
                    CodLinea    = GetIntValue(row, DB_COL_COD_LINEA) + "",
                    Kilometro   = GetIntValue(row, DB_COL_KILOMETRO)
                };

                lstResults.Add(Tren);
            }

            return(lstResults);
        }
Пример #7
0
        public async Task <ActionResult <Tren> > PostTren(Tren tren)
        {
            _context.Tren.Add(tren);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetTren", new { id = tren.id }, tren));
        }
Пример #8
0
        public ActionResult DeleteConfirmed(int id)
        {
            Tren tren = db.Trens.Find(id);

            db.Trens.Remove(tren);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        private void IncluirTransportes()
        {
            Barco barco = new Barco(1, 46);
            Tren  tren  = new Tren(5, 80);

            _empresa.AgregarTransporte(barco);
            _empresa.AgregarTransporte(tren);
        }
        public EstatusCalculos CalcularPorTren()
        {
            Tren tren = new Tren();

            _estatusCalculos.Costo        = tren.CalcularCosto(tren.CostoPorKilometro, _distanciaPedido, MargenUtilidadPorcentaje);
            _estatusCalculos.FechaEntrega = tren.CalcularFechaEntrega(_fechaPedido, tren.CalcularTiempoTrasladoHoras(_distanciaPedido));
            return(_estatusCalculos);
        }
Пример #11
0
 public static int GetTrenIDByName(string name)
 {
     using (TrenEntities t = new TrenEntities())
     {
         Tren tren = t.Tren.Where(x => x.trenAdi.ToLower() == name).FirstOrDefault();
         return(tren.TrenID);
     }
 }
Пример #12
0
 protected override void InicializarTransporte()
 {
     if (Transporte == null)
     {
         Transporte = new Tren(VelocidadTransporte)
         {
             CostoDistancia = _costoDistancia
         };
     }
 }
Пример #13
0
 public ActionResult Edit([Bind(Include = "ID,Rang")] Tren tren)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tren).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(tren));
 }
Пример #14
0
 private void btnArrancarTren_Click(object sender, EventArgs e)
 {
     try
     {
         trenes += (int)this.numericUpDown1.Value;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Пример #15
0
        public ActionResult Create([Bind(Include = "ID,Rang")] Tren tren)
        {
            if (ModelState.IsValid)
            {
                db.Trenuri.Add(tren);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(tren));
        }
Пример #16
0
        public void CalcularTiempoTraslado_VelocidadEntregaCero_ExcepcionDivisionCero()
        {
            //Arrange
            decimal dDistancia = 20m;
            var     SUT        = new Tren(new MetodoEnvioDTO {
                dVelocidadEntrega = 0m
            });

            //Assert
            Assert.ThrowsException <DivideByZeroException>(() => SUT.CalcularTiempoTraslado(dDistancia));
        }
Пример #17
0
 public void DeleteTren(Tren tren)
 {
     if (!string.IsNullOrEmpty(tren.Matricula))
     {
         _crudFactory.Delete(tren);
         //gestorAccion.delete(AccionPara);
     }
     else
     {
         //throw gestor.ControlarExcepcion(new ErpException(ErpException.ExceptionCode.NoHaSeleccionadoCliente));
     }
 }
Пример #18
0
 public void UpdateTren(Tren tren)
 {
     if (!string.IsNullOrEmpty(tren.Matricula))
     {
         _crudFactory.Update(tren);
         gestorAccion.update(AccionPara);
     }
     else
     {
         //throw gestor.ControlarExcepcion(new ErpException(ErpException.ExceptionCode.CedulaNotNull));
     }
 }
Пример #19
0
 public void Insertar(Tren nuevo)
 {
     if (first == null)
     {
         first = nuevo;
     }
     else
     {
         last.siguiente = nuevo;
     }
     last = nuevo;
 }
Пример #20
0
 public void CreateTren(Tren tren)
 {
     if (!string.IsNullOrEmpty(tren.Matricula))
     {
         _crudFactory.Create(tren);
         //gestorAccion.Create(AccionPara);
     }
     else
     {
         throw new Exception();
     }
 }
Пример #21
0
        public ActionResult Edit([Bind(Include = "trenid,cantidad,precio,tipo,cafeteria,compania,origen,destino,numeroplazas")] Tren tren)
        {
            string currentUserId = User.Identity.GetUserId();

            tren.UserId = currentUserId;
            if (ModelState.IsValid)
            {
                db.Entry(tren).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(tren));
        }
Пример #22
0
        public void ObtenerFechaEntrega_ConHorasDosTiempoTraslado_ObtieneFechaEntregaConDosHorasAdicionales()
        {
            //Arrange
            decimal  dTiempoTraslado   = 2m;
            DateTime dtEntregaEsperada = new DateTime(2020, 01, 26, 14, 00, 00);
            DateTime dtPedido          = new DateTime(2020, 01, 26, 12, 00, 00);
            var      SUT = new Tren(new MetodoEnvioDTO());

            //Act
            DateTime dtEntrega = SUT.ObtenerFechaEntrega(dtPedido, dTiempoTraslado);

            //Assert
            Assert.AreEqual(dtEntregaEsperada, dtEntrega);
        }
Пример #23
0
        public void ObtenerFechaEntrega_UnDiaEnHorasTiempoTraslado_ObtieneFechaEntregaDiaSiguiente()
        {
            //Arrange
            decimal  dTiempoTraslado   = 24m;
            DateTime dtEntregaEsperada = new DateTime(2020, 01, 27);
            DateTime dtPedido          = new DateTime(2020, 01, 26);
            var      SUT = new Tren(new MetodoEnvioDTO());

            //Act
            DateTime dtEntrega = SUT.ObtenerFechaEntrega(dtPedido, dTiempoTraslado);

            //Assert
            Assert.AreEqual(dtEntregaEsperada, dtEntrega);
        }
Пример #24
0
        // GET: Tren/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Tren tren = db.Trenuri.Find(id);

            if (tren == null)
            {
                return(HttpNotFound());
            }
            return(View(tren));
        }
Пример #25
0
            public Tren Buscar(string n)
            {
                Tren actual = first;

                while (actual != null)
                {
                    if (actual.Destino == n)
                    {
                        return(actual);
                    }
                    actual = actual.siguiente;
                }
                return(null);
            }
Пример #26
0
        //public static List<TrenModel> GetTrenModels(List<Tren> trenler)
        //{
        //    List<TrenModel> urunModeller = new List<TrenModel>();
        //    foreach (var item in trenler)
        //    {
        //        TrenModel trenModel = new TrenModel()
        //        {
        //            sefer = item.Sefer.
        //            koltukSayisi = item.koltukSayisi,
        //            trenAdi = item.trenAdi,
        //            TrenID = item.TrenID,


        //        };
        //        urunModeller.Add(urunModel);

        //    }
        //    return urunModeller;
        //}
        public static (Tren, bool) Add(Tren tren)
        {
            using (TrenEntities t = new TrenEntities())
            {
                t.Tren.Add(tren);
                if (t.SaveChanges() > 0)
                {
                    return(tren, true);
                }
                else
                {
                    return(tren, false);
                }
            }
        }
Пример #27
0
        public void CalcularTiempoTraslado_DistanciaYVelocidadEntregaValidos_ObtieneTiempoTraslado()
        {
            //Arrange
            decimal dResultadoEsperado = 2m;
            decimal dDistancia         = 20m;
            var     SUT = new Tren(new MetodoEnvioDTO {
                dVelocidadEntrega = 10m
            });

            //Act
            decimal dTiempo = SUT.CalcularTiempoTraslado(dDistancia);

            //Assert
            Assert.AreEqual(dResultadoEsperado, dTiempo);
        }
Пример #28
0
        // GET: Trens/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Tren   tren          = db.Trens.Find(id);
            string currentUserId = User.Identity.GetUserId();

            if ((tren.UserId != currentUserId) || (tren == null))
            {
                return(HttpNotFound());
            }
            return(View(tren));
        }
Пример #29
0
        public void CalcularCostoEnvio_DistanciaYMargenValidos_ObtieneCosto()
        {
            //Arrange
            decimal dCostoEsperado = 52m;
            decimal dDistancia     = 20m;
            decimal dMargen        = 0.30m;
            var     SUT            = new Tren(new MetodoEnvioDTO {
                dCostoKilometro = 2m
            });

            //Act
            decimal dCosto = SUT.CalcularCostoEnvio(dDistancia, dMargen);

            //Assert
            Assert.AreEqual(dCostoEsperado, dCosto);
        }
Пример #30
0
        public void Sobrecargas()
        {
            Tren tren = new Tren();

            try
            {
                tren += -1;
            }
            catch (CantidadInvalidaException ex)
            {
            }
            catch (Exception exep)
            {
                Assert.Fail();
            }
        }