Пример #1
0
        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);
        }
Пример #2
0
 public async static Task <bool> Guardar(SalidaVehiculo salidas)
 {
     if (!await Existe(salidas.SalidaId))
     {
         return(await Insertar(salidas));
     }
     else
     {
         return(await Modificar(salidas));
     }
 }
Пример #3
0
        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);
        }
Пример #4
0
 private void Limpiar()
 {
     salida = new SalidaVehiculo();
     MyPropertyChanged("salida");
 }