private bool ActualizarCombustible(Combustible combustible) { bool resultado = false; using (SqlConnection sqlConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["RESERVAS"].ConnectionString)) { SqlCommand sqlCommand = new SqlCommand( @"UPDATE COMBUSTIBLE SET COMB_TIPO = @COMB_TIPO WHERE COMB_CODIGO = @COMB_CODIGO", sqlConnection); sqlCommand.Parameters.AddWithValue("@COMB_CODIGO", combustible.COMB_CODIGO); sqlCommand.Parameters.AddWithValue("@COMB_TIPO", combustible.COMB_TIPO); sqlConnection.Open(); int filasAfectadas = sqlCommand.ExecuteNonQuery(); if (filasAfectadas > 0) { resultado = true; } sqlConnection.Close(); } return(resultado); }
public void SetItems(int i, string value) { switch (i) { case 0: VIN = (string)value; break; case 1: Modelo = (string)value; break; case 2: Color = (string)value; break; case 3: Marca = (string)value; break; case 4: TipoCombustible = (Combustible)Combustible.Parse(typeof(Combustible), value.ToString()); break; case 5: TipoTransmision = (Transmision)Transmision.Parse(typeof(Transmision), value.ToString()); break; case 6: IdCarro = Convert.ToInt32(value); break; } }
public IHttpActionResult GetId(int id) { Combustible combustible = new Combustible(); try { using (SqlConnection sqlConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["RESERVAS"].ConnectionString)) { SqlCommand sqlCommand = new SqlCommand( @"SELECT COMB_CODIGO, COMB_TIPO FROM COMBUSTIBLE WHERE COMB_CODIGO = @COMB_CODIGO", sqlConnection); sqlCommand.Parameters.AddWithValue("@COMB_CODIGO", id); sqlConnection.Open(); SqlDataReader sqlDataReader = sqlCommand.ExecuteReader(); while (sqlDataReader.Read()) { combustible.COMB_CODIGO = sqlDataReader.GetInt32(0); combustible.COMB_TIPO = sqlDataReader.GetString(1); } sqlConnection.Close(); } } catch (Exception e) { return(InternalServerError(e)); } return(Ok(combustible)); }
private bool RegistrarCombustible(Combustible combustible) { bool resultado = false; using (SqlConnection sqlConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["RESERVAS"].ConnectionString)) { SqlCommand sqlCommand = new SqlCommand( @"INSERT INTO COMBUSTIBLE (COMB_TIPO) VALUES(@COMB_TIPO)", sqlConnection); sqlCommand.Parameters.AddWithValue("@COMB_TIPO", combustible.COMB_TIPO); sqlConnection.Open(); int filasAfectadas = sqlCommand.ExecuteNonQuery(); if (filasAfectadas > 0) { resultado = true; } sqlConnection.Close(); } return(resultado); }
public Vehiculo(double precio, Combustible comb, Categoria cat, Trasmision trans) { this.PrecioBase = precio; this.Combustible = comb; this.Categoria = cat; this.Trasmision = trans; }
public IHttpActionResult GetAll() { List <Combustible> combustibles = new List <Combustible>(); try { using (SqlConnection sqlConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["RESERVAS"].ConnectionString)) { SqlCommand sqlCommand = new SqlCommand( @"SELECT COMB_CODIGO, COMB_TIPO FROM COMBUSTIBLE", sqlConnection); sqlConnection.Open(); SqlDataReader sqlDataReader = sqlCommand.ExecuteReader(); while (sqlDataReader.Read()) { Combustible combustible = new Combustible() { COMB_CODIGO = sqlDataReader.GetInt32(0), COMB_TIPO = sqlDataReader.GetString(1) }; combustibles.Add(combustible); } sqlConnection.Close(); } } catch (Exception e) { return(InternalServerError(e)); } return(Ok(combustibles)); }
public Vehiculo(string marca, string modelo, int kilometros, Combustible combustible) { this.Marca = marca; this.Modelo = modelo; this.Kilometros = kilometros; this.Combustible = combustible; }
public ActionResult DeleteConfirmed(int id) { Combustible combustible = db.Combustibles.Find(id); db.Combustibles.Remove(combustible); db.SaveChanges(); return(RedirectToAction("Index")); }
public async Task <Combustible> Actualizar(Combustible combustible, string token) { HttpClient client = GetClient(token); var response = await client.PutAsync(URL, new StringContent(JsonConvert.SerializeObject(combustible), Encoding.UTF8, "application/json")); return(JsonConvert.DeserializeObject <Combustible>(await response.Content.ReadAsStringAsync())); }
public CombustibleDTO CombustibleToDTO(Combustible combustible) { return(new CombustibleDTO { Id = combustible.IdCombustible, Descripcion = combustible.Descripcion, Codigo = combustible.Codigo }); }
private async Task CombustibleValidation(Combustible combustible) { var currentCombustible = await _unitOfWork.CombustibleRepository.GetAll(); if (currentCombustible.Where(x => x.TipoCombustible.ToString().ToLower() == combustible.TipoCombustible.ToString().ToLower()).Any()) { throw new BussinessException("Ya existe este combustible", 400); } }
public ActionResult Edit(Combustible combustible) { if (ModelState.IsValid) { db.Entry(combustible).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(combustible)); }
public void NoEncenderVoid() { var aceite = new Aceite(0); var combustibles = new Combustible(100); var motor = new Motor(aceite, combustibles); var Resultado = new Auto(motor); Resultado.Encender(); }
public void NoArrancarVoid() { var aceite = new Aceite(0); var combustibles = new Combustible(0); var motor = new Motor(aceite, combustibles); var Resultado = new Auto(motor); Resultado.Arrancar(); }
public void NivelFalse() { var Valor_Esperado = false; var combustible = new Combustible(0); var Valor_Actual = combustible.Nivel(); Assert.AreEqual(Valor_Esperado, Valor_Actual); }
public void NivelTrue() { var Valor_Esperado = true; var combustible = new Combustible(100); var Valor_Actual = combustible.Nivel(); Assert.AreEqual(Valor_Esperado, Valor_Actual); }
public async Task InsertCombustible(Combustible combustible) { await CombustibleValidation(combustible); combustible.Id = 0; combustible.Estatus = true; await _unitOfWork.CombustibleRepository.Add(combustible); await _unitOfWork.SaveChangesAsync(); }
private IEnumerator Cooldown(Combustible combustible) { yield return(new WaitForSeconds(combustible.duration)); naveController.inBoost = false; StartCoroutine(DeactivateFuelAnimation("Turbo")); yield return(new WaitForSeconds(cooldown)); inTurbo = false; }
public static void Main(string[] args) { var aceite = new Aceite(100); var combustibles = new Combustible(100); var motor = new Motor(aceite, combustibles); var auto = new Auto(motor); auto.Encender(); auto.Arrancar(); Console.ReadLine(); }
public ActionResult Create(Combustible combustible) { if (ModelState.IsValid) { db.Combustibles.Add(combustible); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(combustible)); }
public async Task <bool> UpdateCombustible(Combustible combustible) { var currentCombustible = await GetCombustible(combustible.Id); currentCombustible.Descripcion = combustible.Descripcion; combustible.Estatus = combustible.Estatus ?? true; _unitOfWork.CombustibleRepository.Update(currentCombustible); await _unitOfWork.SaveChangesAsync(); return(true); }
private void GetFuel() { foreach (Combustible c in objetoCombustibles.GetComponentsInChildren <Combustible>()) { if (c.tipoCombustible == tipoCombustible) { combustible = c; return; } } }
public void EstaEncendidoFalse() { var Valor_Esperado = false; var aceite = new Aceite(0); var combustibles = new Combustible(0); var motor = new Motor(aceite, combustibles); var Valor_Actual = motor.EstaEncendido(); Assert.AreEqual(Valor_Esperado, Valor_Actual); }
public ActionResult EditarCombustible(int id) { var combustibleBD = _context.Combustibles.SingleOrDefault(c => c.Id == id); if (combustibleBD == null) { return(HttpNotFound()); } var combustible = new Combustible(combustibleBD); return(View("CombustibleFormulario", combustible)); }
// GET: Combustibles/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Combustible combustible = db.Combustibles.Find(id); if (combustible == null) { return(HttpNotFound()); } return(View(combustible)); }
public void GetFuel() { Component[] combustibles; combustibles = GetComponents(typeof(Combustible)); if (combustibles != null) { foreach (Combustible c in combustibles) { if (c.tipoCombustible == tipoCombustible) { combustible = c; } } } }
public IHttpActionResult Ingresar(Combustible combustible) { if (combustible == null) { return(BadRequest()); } if (RegistrarCombustible(combustible)) { return(Ok(combustible)); } else { return(InternalServerError()); } }
public IHttpActionResult Put(Combustible combustible) { if (combustible == null) { return(BadRequest()); } if (ActualizarCombustible(combustible)) { return(Ok(combustible)); } else { return(InternalServerError()); } }
// Simple interaction method to determine user input from mouse // Based on InteractionMode enum set through the user panel it process the input private void ProcessInteraction() { if (Input.GetKeyDown(controlsConfig.lbm)) { RaycastHit hit; if (Physics.Raycast(GetMouseRay(), out hit, interactionLayerMask)) { switch (interactionMode) { // Adding plants case InteractionMode.Add: if (hit.transform.GetComponent <Combustible>() == null) { vegetationFactory.SpawnFlower(hit.point); } break; // Removing plants case InteractionMode.Remove: Flower flower = hit.transform.GetComponent <Flower>(); if (flower != null) { vegetationFactory.RemoveFlower(flower); } break; // Toggle between ignition and extinguishing case InteractionMode.Toggle: Combustible combustible = hit.transform.GetComponent <Combustible>(); if (combustible == null) { return; } if (combustible.IsBurning()) { combustible.Extinguish(); } else { weatherControl.IgniteFire(hit.point); } break; } } } ; }
public HttpResponseMessage detail(int id) { Combustible combustible = combustible_service.detail(id); if (combustible != null) { IDictionary <string, Combustible> data = new Dictionary <string, Combustible>(); data.Add("data", combustible); return(Request.CreateResponse(HttpStatusCode.OK, data)); } else { IDictionary <string, string> data = new Dictionary <string, string>(); data.Add("message", "Object not found."); return(Request.CreateResponse(HttpStatusCode.BadRequest, data)); } }