public int getEmpXCredenciales(string userName, string password) { try { using (TeamCellContext _dbContext = new TeamCellContext()) { var user = _dbContext.User.FirstOrDefault(x => x.UserName == userName); if (user != null) { byte[] hashedPassword = Cryptographic.HashPasswordWithSalt(Encoding.UTF8.GetBytes(password), user.Salt); if (hashedPassword.SequenceEqual(user.Password)) { return(user.IdEmployee); } else { return(0); } } return(0); } } catch (Exception) { return(0); } }
public List <object> StockGlobal() { try { using (TeamCellContext _BDContext = new TeamCellContext()) { List <Product> lstID = _BDContext.Product.ToList(); KardexController kardCont = new KardexController(); List <object> result = null; foreach (Product i in lstID) { result.Add(new { Codigo = i.Codigo, Nombre = i.Name, Stock = kardCont.GetStockActual(i.IdProducto) }); } return(result); } } catch (Exception e) { return(new List <object>()); } }
public decimal getCalcularPromedioSimpre(int id) { try { using (TeamCellContext _DBContext = new TeamCellContext()) { var TotalMonto = (from k in _DBContext.Kardex join ct in _DBContext.CostingAverage on k.IdKardex equals ct.IdKardex where k.IdProducto == id select new { ct.Cost }).Sum(x => x.Cost); var TotalCant = (from k in _DBContext.Kardex join ct in _DBContext.CostingAverage on k.IdKardex equals ct.IdKardex where k.IdProducto == id select new { ct.Cost }).Count(); return(TotalMonto / TotalCant); } } catch { return(0); } }
public Client GetIdClient(int id) { try { using (TeamCellContext _DBContext = new TeamCellContext()) { return(_DBContext.Client.Where(x => x.Id == id).FirstOrDefault()); } } catch (Exception e) { return(new Client()); } }
public Country GetIdCountry(int id) { try { using (TeamCellContext _DBContext = new TeamCellContext()) { return(_DBContext.Country.Where(x => x.IdCountry == id).FirstOrDefault()); } } catch (Exception e) { return(new Country()); } }
public DetailPurchase GetdetailPurchase(int id) { try { using (TeamCellContext _DBContext = new TeamCellContext()) { return(_DBContext.DetailPurchase.Where(x => x.IdDetailPurchase == id).FirstOrDefault()); } } catch (Exception e) { return(new DetailPurchase()); } }
public Purchases GetIdPurchases(int id) { try { using (TeamCellContext _DBContext = new TeamCellContext()) { return(_DBContext.Purchases.Where(x => x.IdPurchases == id).FirstOrDefault()); } } catch (Exception e) { return(new Purchases()); } }
public CostingWeighted getCostingWeightedXId(int id) { try { using (TeamCellContext _DBContext = new TeamCellContext()) { return(_DBContext.CostingWeighted.Where(x => x.IdCostingWeighted == id).FirstOrDefault()); } } catch { return(new CostingWeighted()); } }
public Product getIdProduct(int id) { try { using (TeamCellContext _BDContext = new TeamCellContext()) { return(_BDContext.Product.Where(x => x.IdProducto == id).FirstOrDefault()); } } catch (Exception e) { return(new Product()); } }
public Provider getProviderXId(int id) { try { using (TeamCellContext _DBContext = new TeamCellContext()) { return(_DBContext.Provider.Where(x => x.IdProvider == id).FirstOrDefault()); } } catch { return(new Provider()); } }
public Employee getEmployeeXId(int id) { try { using (TeamCellContext _DBContext = new TeamCellContext()) { return(_DBContext.Employee.Where(x => x.IdEmployee == id).FirstOrDefault()); } } catch { return(new Employee()); } }
public Warehouse getWarehouseXId(int id) { try { using (TeamCellContext _DBContext = new TeamCellContext()) { return(_DBContext.Warehouse.Where(x => x.IdWarehouse == id).FirstOrDefault()); } } catch { return(new Warehouse()); } }
public Brand getBrandXId(int id) { try { using (TeamCellContext _DBContext = new TeamCellContext()) { return(_DBContext.Brand.Where(x => x.IdBrand == id).FirstOrDefault()); } } catch { return(new Brand()); } }
public CostingAverage getCostingAverageXId(int id) { try { using (TeamCellContext _DBContext = new TeamCellContext()) { return(_DBContext.CostingAverage.Where(x => x.IdCostingAverage == id).FirstOrDefault()); } } catch { return(new CostingAverage()); } }
public Kardex GetIdKardex(int id) { try { using (TeamCellContext _DBContext = new TeamCellContext()) { return(_DBContext.Kardex.Where(x => x.IdKardex == id).FirstOrDefault()); } } catch (Exception e) { return(new Kardex()); } }
public DetailBilling GetDetailBilling(int id) { try { using (TeamCellContext _DBContext = new TeamCellContext()) { return(_DBContext.DetailBilling.Where(x => x.IdDetailBilling == id).FirstOrDefault()); } } catch (Exception e) { return(new DetailBilling()); } }
public List <Country> getCountry() { try { using (TeamCellContext _BDContext = new TeamCellContext()) { var result = _BDContext.Country.ToList(); return(result); } } catch (Exception e) { return(new List <Country>()); } }
public List <Provider> getProvider() { try { using (TeamCellContext _DBContext = new TeamCellContext()) { var result = _DBContext.Provider.ToList(); return(result); } } catch { return(new List <Provider>()); } }
public List <Brand> getBrand() { try { using (TeamCellContext _BDContext = new TeamCellContext()) { var result = _BDContext.Brand.ToList(); return(result); } } catch (Exception e) { return(new List <Brand>()); } }
public List <CostingAverage> getCostingAverage() { try { using (TeamCellContext _BDContext = new TeamCellContext()) { var result = _BDContext.CostingAverage.ToList(); return(result); } } catch (Exception e) { return(new List <CostingAverage>()); } }
public decimal GetStockActual(int idProducto) { try { using (TeamCellContext _BDContext = new TeamCellContext()) { decimal result = _BDContext.Kardex.Where(x => x.IdProducto == idProducto).Sum(x => x.EntryAmount - x.OutputAmount); return(result); } } catch (Exception) { return(0); } }
public List <Product> getProduct() { try { using (TeamCellContext _BDContext = new TeamCellContext()) { var result = _BDContext.Product.ToList(); return(result); } } catch (Exception e) { return(new List <Product>()); } }
public List <DetailPurchase> getDetailsPurchases(int id) { try { using (TeamCellContext _BDContext = new TeamCellContext()) { var result = _BDContext.DetailPurchase.Where(x => x.IdPurchases == id).ToList(); return(result); } } catch (Exception e) { return(new List <DetailPurchase>()); } }
public List <Client> GetClient() { try { using (TeamCellContext _BDContext = new TeamCellContext()) { var result = _BDContext.Client.ToList(); return(result); } } catch (Exception) { return(new List <Client>()); } }
public List <DetailBilling> getDetailBilling(int id) { try { using (TeamCellContext _BDContext = new TeamCellContext()) { var result = _BDContext.DetailBilling.Where(x => x.IdDetailBilling == id).ToList(); return(result); } } catch (Exception e) { return(new List <DetailBilling>()); } }
public User getUserXId(int idUser) { try { using (TeamCellContext _dbContext = new TeamCellContext()) { var user = _dbContext.User.Include(x => x.Employee).FirstOrDefault(x => x.IdUser == idUser); return(user); } } catch (Exception) { return(new User()); } }
public List <Purchases> getPurchases() { try { using (TeamCellContext _BDContext = new TeamCellContext()) { var result = _BDContext.Purchases.ToList(); return(result); } } catch (Exception e) { return(new List <Purchases>()); } }
public List <User> getUsersActive() { try { using (TeamCellContext _dbContext = new TeamCellContext()) { var listUser = _dbContext.User.Include(x => x.Employee).Where(x => x.Status == true).ToList(); return(listUser); } } catch (Exception ex) { return(new List <User>()); } }
public List <Warehouse> getWarehouse() { try { using (TeamCellContext _BDContext = new TeamCellContext()) { var result = _BDContext.Warehouse.ToList(); return(result); } } catch (Exception e) { return(new List <Warehouse>()); } }
public List <Employee> getEmployees() { try { using (TeamCellContext _DBContext = new TeamCellContext()) { var result = _DBContext.Employee.ToList(); return(result); } } catch { return(new List <Employee>()); } }