Beispiel #1
0
        public void Save(VehiculosTipos tipo, SaveAction accion)
        {
            using (var ctx = new GrullonRCEntities())
            {
                if (accion == SaveAction.Agregar)
                {
                    ctx.VehiculosTipos.Add(tipo);
                }

                if (accion == SaveAction.Editar)
                {
                    var toUpdate = ctx.VehiculosTipos.FirstOrDefault(x => x.Id == tipo.Id);
                    toUpdate.Descripcion = tipo.Descripcion;
                    toUpdate.Estado      = tipo.Estado;
                }

                if (accion == SaveAction.Eliminar)
                {
                    var toDelete = ctx.VehiculosTipos.FirstOrDefault(x => x.Id == tipo.Id);
                    toDelete.Deleted = true;
                }

                ctx.SaveChanges();
            }
        }
Beispiel #2
0
 public CombustiblesTipos GetSingleTipo(int id)
 {
     using (var ctx = new GrullonRCEntities())
     {
         return(ctx.CombustiblesTipos.FirstOrDefault(v => v.Id == id));
     }
 }
Beispiel #3
0
 public VehiculosTipos GetSingleTipo(int id)
 {
     using (var ctx = new GrullonRCEntities())
     {
         return(ctx.VehiculosTipos.FirstOrDefault(v => v.Id == id));
     }
 }
 public Marcas GetSingleTipo(string descripcion)
 {
     using (var ctx = new GrullonRCEntities())
     {
         return(ctx.Marcas.FirstOrDefault(v => v.Descripcion == descripcion));
     }
 }
 public Marcas GetSingleTipo(int id)
 {
     using (var ctx = new GrullonRCEntities())
     {
         return(ctx.Marcas.FirstOrDefault(v => v.Id == id));
     }
 }
Beispiel #6
0
 public List <VehiculosTipos> GetTipos(string search)
 {
     using (var ctx = new GrullonRCEntities())
     {
         return(ctx.VehiculosTipos
                .Where(x => !x.Deleted && ((search == null || search == "") ||
                                           (x.Descripcion.Contains(search))))
                .ToList());
     }
 }
Beispiel #7
0
        public bool Login(string username, string password)
        {
            using (var ctx = new GrullonRCEntities())
            {
                var empleado = ctx.Empleados.FirstOrDefault(user => user.User == username && user.Password == password);

                if (empleado != null)
                {
                    AppData.CurrentSession.CurrentUser = empleado;
                    return(true);
                }

                return(false);
            }
        }
        public List <Marcas> GetTipos(string search, bool combo = false)
        {
            using (var ctx = new GrullonRCEntities())
            {
                if (combo)
                {
                    ctx.Marcas
                    .Where(x => !x.Deleted && x.Estado)
                    .ToList();
                }

                return(ctx.Marcas
                       .Where(x => !x.Deleted && ((search == null || search == "") ||
                                                  (x.Descripcion.Contains(search))))
                       .ToList());
            }
        }