/// <summary> /// Will insert a HousingComplex into the database /// </summary> /// <param name="housecom"></param> /// <returns>return true if added</returns> public bool InsertHousingComplex(HousingComplex housecom) { housecom.ActiveBit = true; try { db.HousingComplex.Add(housecom); if (db.SaveChanges() == 0) { return(false); } return(true); } catch (Exception) { return(false); } }
/// <summary> /// Will update HousingComplex in database /// </summary> /// <param name="housecom"></param> /// <returns>return true if object found</returns> public bool UpdateHousingComplex(HousingComplex housecom) { try { var oldhousecom = db.HousingComplex.FirstOrDefault(h => h.HotelID == housecom.HotelID); if (oldhousecom != null) { db.Entry(oldhousecom).CurrentValues.SetValues(housecom); db.SaveChanges(); return(true); } return(false); } catch (Exception) { return(false); } }