public static Personal searchUserById(int idUser)
 {
     try
     {
         using (var model = new oficinasymasEntities())
         {
             var result = model.Personals.Where(user => (user.idPersonal == idUser)).FirstOrDefault();
             return(result);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public static bool emailExists(string emailToValidate)
 {
     try
     {
         using (var model = new oficinasymasEntities())
         {
             var result = model.Personals.Where(user => (user.correo == emailToValidate)).ToList();
             return(result.Count() > 0);
         }
     }
     catch
     {
         return(false);
     }
 }
 public static void insertUser(Personal newUser)
 {
     try
     {
         using (var model = new oficinasymasEntities())
         {
             model.Personals.Add(newUser);
             model.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw ex;
     };
 }
Пример #4
0
 public static Mueble searchMuebleById(int idMueble)
 {
     try
     {
         using (var model = new oficinasymasEntities())
         {
             var result = model.Muebles.Where(mueble => (mueble.idMueble == idMueble)).FirstOrDefault();
             return(result);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public static Personal login(Personal login)
 {
     try
     {
         using (var model = new oficinasymasEntities())
         {
             var result = model.Personals.Where(user => (user.correo == login.correo && user.password == login.password)).FirstOrDefault();
             return(result);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Пример #6
0
 public static void insertMueble(Mueble newMueble)
 {
     try
     {
         using (var model = new oficinasymasEntities())
         {
             model.Muebles.Add(newMueble);
             model.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw ex;
     };
 }
 public static List <Personal> searchUserByCriteria(string criteria)
 {
     try
     {
         using (var model = new oficinasymasEntities())
         {
             List <Personal> result = model.Personals.Where(user => (user.nombre.Contains(criteria) ||
                                                                     user.correo.Contains(criteria))).ToList();
             return(result);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Пример #8
0
 public static List <Mueble> searchMuebleByCriteria(string criteria)
 {
     try
     {
         using (var model = new oficinasymasEntities())
         {
             List <Mueble> result = model.Muebles.Where(mueble => (mueble.nombre.Contains(criteria) ||
                                                                   mueble.color.Contains(criteria) || mueble.categoria.Contains(criteria))).ToList();
             return(result);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public static void removeUser(int idUserToRemove)
 {
     try
     {
         Personal userToRemove = searchUserById(idUserToRemove);
         using (var model = new oficinasymasEntities())
         {
             model.Personals.Attach(userToRemove);
             model.Personals.Remove(userToRemove);
             model.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Пример #10
0
 public static void removeMueble(int idMuebleToRemove)
 {
     try
     {
         Mueble muebleToRemove = searchMuebleById(idMuebleToRemove);
         using (var model = new oficinasymasEntities())
         {
             model.Muebles.Attach(muebleToRemove);
             model.Muebles.Remove(muebleToRemove);
             model.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Пример #11
0
 public static List <Mueble> searchMuebleByMultipleId(List <int> muebleList)
 {
     try
     {
         using (var model = new oficinasymasEntities())
         {
             foreach (var item in muebleList)
             {
                 List <Mueble> result = model.Muebles.Where(mueble => (mueble.idMueble == item)).ToList();
                 return(result);
             }
             return(null);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public static void updateUser(Personal userToUpdate)
 {
     try
     {
         using (var model = new oficinasymasEntities())
         {
             Personal user = model.Personals.Find(userToUpdate.idPersonal);
             user.nombre   = userToUpdate.nombre;
             user.apellido = userToUpdate.apellido;
             user.area     = userToUpdate.correo;
             user.correo   = userToUpdate.correo;
             user.telefono = userToUpdate.telefono;
             user.password = userToUpdate.password;
             model.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Пример #13
0
 public static void updateMueble(Mueble muebleToUpdate)
 {
     try
     {
         using (var model = new oficinasymasEntities())
         {
             Mueble mueble = model.Muebles.Find(muebleToUpdate.idMueble);
             mueble.nombre         = muebleToUpdate.nombre;
             mueble.color          = muebleToUpdate.color;
             mueble.precio         = muebleToUpdate.precio;
             mueble.image          = muebleToUpdate.image;
             mueble.cantidad_stock = muebleToUpdate.cantidad_stock;
             mueble.categoria      = muebleToUpdate.categoria;
             model.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public static void editUser(Personal modifiedUser)
 {
     try
     {
         using (var model = new oficinasymasEntities())
         {
             Personal user = model.Personals.Find(modifiedUser.idPersonal);
             user.nombre   = modifiedUser.nombre;
             user.apellido = modifiedUser.apellido;
             user.correo   = modifiedUser.correo;
             user.password = modifiedUser.password;
             user.telefono = modifiedUser.telefono;
             user.rol      = modifiedUser.rol;
             user.area     = modifiedUser.area;
             model.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }