public void CloseConnection() { if (db != null) { db = null; } }
private int?GetUserShopId(string login) { using (var db = new mshopEntities(loginuser, loginpassword)) { try { var user = db.Users.Where(item => item.Login == login).ToList(); int?shopId = user[0].S_Id; return(shopId); } catch (Exception e) { throw new NotImplementedException(); } } }
public string GetWorkingPlaceOfUser(string login) { using (var db = new mshopEntities(loginuser, loginpassword)) { try { string query = "CALL work_place('" + login + "');"; string s = db.Database.SqlQuery <string>(query).ToString(); return(s); } catch { return(null); } } }
public bool UserExists(string username, string password) { using (var db = new mshopEntities(username, password)) { try { db.SetCommandTimeOut(1); db.Database.Connection.Open(); return(true); } catch { return(false); } finally { db.SetCommandTimeOut(100); } } }
public bool OpenConnection(ConnectionType connectionType) { try { db = new mshopEntities(Login, Password); db.Database.Connection.Open(); if (connectionType == ConnectionType.Shop) { ShopModel = new ShopModel(db, GetUserShopId(Login)); } else if (connectionType == ConnectionType.Warehouse) { WarehouseModel = new WarehouseModel(db, GetUserWarehouseId(Login)); } return(true); } catch (Exception e) { return(false); } }
public ShopModel(mshopEntities database, int?cS) { db = database; currentShop = cS; }
public WarehouseModel(mshopEntities database, int?cW) { db = database; currentWarehouse = cW; }