public static tblManager AddManager(tblManager manager) { try { using (dbHotelEntities context = new dbHotelEntities()) { if (manager.managerId == 0) { //add tblManager newManager = new tblManager(); newManager.name = "manager"; newManager.userId = manager.userId; newManager.floorNumber = manager.floorNumber; newManager.workExperience = manager.workExperience; newManager.qualificationId = manager.qualificationId; context.tblManagers.Add(newManager); context.SaveChanges(); manager.managerId = newManager.managerId; return(manager); } return(manager); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("Exception: " + ex.Message.ToString()); return(null); } }
public static tblManager getManager(int userId) { try { using (dbHotelEntities context = new dbHotelEntities()) { tblManager res = (from x in context.tblManagers where x.userId == userId select x).FirstOrDefault(); return(res); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("Exception " + ex.Message.ToString()); return(null); } }