private async static Task <bool> Insertar(SalidaVehiculo salida) { bool paso = false; Contexto contexto = new Contexto(); try { contexto.salidaVehiculos.Add(salida); paso = await contexto.SaveChangesAsync() > 0; if (paso) { Vehiculo vehiculo = await VehiculoBLL.Buscar(salida.VehiculoId); if (vehiculo != null) { vehiculo.Estado = Entidades.Enums.VehiculoEstado.Eliminado; await VehiculoBLL.Modificar(vehiculo); } } } catch (Exception) { throw; } finally { await contexto.DisposeAsync(); } return(paso); }
public async static Task <bool> Guardar(SalidaVehiculo salidas) { if (!await Existe(salidas.SalidaId)) { return(await Insertar(salidas)); } else { return(await Modificar(salidas)); } }
public async static Task <bool> Modificar(SalidaVehiculo salida) { bool paso = false; Contexto contexto = new Contexto(); try { contexto.Entry(salida).State = EntityState.Modified; paso = await contexto.SaveChangesAsync() > 0; } catch (Exception) { throw; } finally { await contexto.DisposeAsync(); } return(paso); }
private void Limpiar() { salida = new SalidaVehiculo(); MyPropertyChanged("salida"); }