public int SearchPassId(string pass, string log) { using (CalorieCalculatorDBEntities1 db = new CalorieCalculatorDBEntities1()) { PassStore passList = new PassStore(); passList = db.PassStore.FirstOrDefault(x => x.Pass == pass && x.Login == log); return(passList.PassStoreId); } }
public void RemoveUser(int id) { using (CalorieCalculatorDBEntities1 db = new CalorieCalculatorDBEntities1()) { UserInfo user = db.UserInfo.FirstOrDefault(x => x.UserId == id); PassStore pass = db.PassStore.FirstOrDefault(x => x.PassStoreId == user.PassStoreId); db.UserInfo.Remove(user); db.PassStore.Remove(pass); db.SaveChanges(); } }
public void AddPassLog(string pass, string log) { using (CalorieCalculatorDBEntities1 db = new CalorieCalculatorDBEntities1()) { if (db.PassStore.Any(x => x.Pass == pass && x.Login == log)) { throw (new Exception("Такие логин и пароль уже существуют!")); } PassStore passLog = new PassStore { Pass = pass, Login = log }; db.PassStore.Add(passLog); db.SaveChanges(); } }