//Update a record public static int UpdateRecord(etblPropertyDiningMap eobj) { int retval = 0; using (OneFineRateEntities db = new OneFineRateEntities()) { try { OneFineRate.tblPropertyDiningMap obj = (OneFineRate.tblPropertyDiningMap)OneFineRateAppUtil.clsUtils.ConvertToObject(eobj, new OneFineRate.tblPropertyDiningMap()); db.tblPropertyDiningMaps.Attach(obj); db.Entry(obj).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); retval = 1; //var checkExistsRestaurantName = db.tblPropertyDiningMaps.Any( // p => p.iPropId == eobj.iPropId // && p.iRestaurantID != eobj.iRestaurantID // && p.sRestaurantName == eobj.sRestaurantName); //if (checkExistsRestaurantName == false) //{ //} //else //{ // retval = 2; //} } catch (Exception) { throw; } } return(retval); }
//Add new record public static int AddRecord(etblPropertyDiningMap eobj) { int retval = 0; using (OneFineRateEntities db = new OneFineRateEntities()) { try { var checkExistsRestaurantName = db.tblPropertyDiningMaps.Any( p => p.iPropId == eobj.iPropId && p.sRestaurantName == eobj.sRestaurantName); if (checkExistsRestaurantName == false) { OneFineRate.tblPropertyDiningMap dbstate = (OneFineRate.tblPropertyDiningMap)OneFineRateAppUtil.clsUtils.ConvertToObject(eobj, new OneFineRate.tblPropertyDiningMap()); db.tblPropertyDiningMaps.Add(dbstate); db.SaveChanges(); retval = 1; } else { retval = 2; } } catch (Exception) { throw; } } return(retval); }