//Update a record public static int UpdateRecord(eRatePlan eobj) { int retval = 0; using (OneFineRateEntities db = new OneFineRateEntities()) { try { int dbobj = (from s in db.tblRatePlanMs.Where(u => u.sRatePlan == eobj.sRatePlan.Trim() && u.iRatePlanId != eobj.iRatePlanId) select new { s.iRatePlanId, }).Count(); if (dbobj > 0) { return(retval = 2); } OneFineRate.tblRatePlanM obj = (OneFineRate.tblRatePlanM)OneFineRateAppUtil.clsUtils.ConvertToObject(eobj, new OneFineRate.tblRatePlanM()); db.tblRatePlanMs.Attach(obj); db.Entry(obj).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); retval = 1; } catch (Exception) { throw; } } return(retval); }
//Add new record public static int AddRecord(eRatePlan eobj) { int retval = 0; using (OneFineRateEntities db = new OneFineRateEntities()) { try { int dbobj = (from s in db.tblRatePlanMs.Where(u => u.sRatePlan == eobj.sRatePlan.Trim()) select new { s.iRatePlanId, }).Count(); if (dbobj > 0) { return(retval = 2); } OneFineRate.tblRatePlanM dbuser = (OneFineRate.tblRatePlanM)OneFineRateAppUtil.clsUtils.ConvertToObject(eobj, new OneFineRate.tblRatePlanM()); db.tblRatePlanMs.Add(dbuser); db.SaveChanges(); retval = 1; } catch (Exception) { throw; } } return(retval); }