//Update a record public static int UpdateRecord(eChains eobj) { int retval = 0; using (OneFineRateEntities db = new OneFineRateEntities()) { try { int dbobj = (from s in db.tblChainMs.Where(u => u.sChainName == eobj.sChainName.Trim() && u.iChainID != eobj.iChainID) select new { s.iChainID, }).Count(); if (dbobj > 0) { return(retval = 2); } OneFineRate.tblChainM obj = (OneFineRate.tblChainM)OneFineRateAppUtil.clsUtils.ConvertToObject(eobj, new OneFineRate.tblChainM()); db.tblChainMs.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(eChains eobj) { int retval = 0; using (OneFineRateEntities db = new OneFineRateEntities()) { try { int dbobj = (from s in db.tblChainMs.Where(u => u.sChainName == eobj.sChainName.Trim()) select new { s.sChainName, }).Count(); if (dbobj > 0) { return(retval = 2); } OneFineRate.tblChainM dbuser = (OneFineRate.tblChainM)OneFineRateAppUtil.clsUtils.ConvertToObject(eobj, new OneFineRate.tblChainM()); db.tblChainMs.Add(dbuser); db.SaveChanges(); retval = 1; } catch (Exception) { throw; } } return(retval); }