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); } }
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(); }
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()); }
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); }
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); }
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); }
public async Task <ActionResult <Tren> > PostTren(Tren tren) { _context.Tren.Add(tren); await _context.SaveChangesAsync(); return(CreatedAtAction("GetTren", new { id = tren.id }, tren)); }
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); }
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); } }
protected override void InicializarTransporte() { if (Transporte == null) { Transporte = new Tren(VelocidadTransporte) { CostoDistancia = _costoDistancia }; } }
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)); }
private void btnArrancarTren_Click(object sender, EventArgs e) { try { trenes += (int)this.numericUpDown1.Value; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public ActionResult Create([Bind(Include = "ID,Rang")] Tren tren) { if (ModelState.IsValid) { db.Trenuri.Add(tren); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tren)); }
public void CalcularTiempoTraslado_VelocidadEntregaCero_ExcepcionDivisionCero() { //Arrange decimal dDistancia = 20m; var SUT = new Tren(new MetodoEnvioDTO { dVelocidadEntrega = 0m }); //Assert Assert.ThrowsException <DivideByZeroException>(() => SUT.CalcularTiempoTraslado(dDistancia)); }
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)); } }
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)); } }
public void Insertar(Tren nuevo) { if (first == null) { first = nuevo; } else { last.siguiente = nuevo; } last = nuevo; }
public void CreateTren(Tren tren) { if (!string.IsNullOrEmpty(tren.Matricula)) { _crudFactory.Create(tren); //gestorAccion.Create(AccionPara); } else { throw new Exception(); } }
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)); }
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); }
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); }
// 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)); }
public Tren Buscar(string n) { Tren actual = first; while (actual != null) { if (actual.Destino == n) { return(actual); } actual = actual.siguiente; } return(null); }
//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); } } }
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); }
// 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)); }
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); }
public void Sobrecargas() { Tren tren = new Tren(); try { tren += -1; } catch (CantidadInvalidaException ex) { } catch (Exception exep) { Assert.Fail(); } }