//Add new Banner public static int AddRecord(etblBannerM eobj) { int retval = 0; using (OneFineRateEntities db = new OneFineRateEntities()) { try { bool chkPageBottom = false; bool chkExists = db.tblBannerMs.Any( p => p.sBannerName == eobj.sBannerName //&& p.sBannerType == eobj.sBannerType && p.cstatus == eobj.cstatus ); if (eobj.sBannerType == "Page Bottom") { chkPageBottom = db.tblBannerMs.Any( p => p.sBannerType == eobj.sBannerType ); } if (chkExists != true) { if (chkPageBottom != true) { OneFineRate.tblBannerM dbuser = (OneFineRate.tblBannerM)OneFineRateAppUtil.clsUtils.ConvertToObject(eobj, new OneFineRate.tblBannerM()); db.tblBannerMs.Add(dbuser); db.SaveChanges(); retval = 1; } else { retval = 3; } } else { retval = 2; } } catch (Exception) { throw; } } return(retval); }
//Update new Banner public static int UpdateRecord(etblBannerM eobj) { int retval = 0; using (OneFineRateEntities db = new OneFineRateEntities()) { try { OneFineRate.tblBannerM obj = (OneFineRate.tblBannerM)OneFineRateAppUtil.clsUtils.ConvertToObject(eobj, new OneFineRate.tblBannerM()); db.tblBannerMs.Attach(obj); db.Entry(obj).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); retval = 1; } catch (Exception) { throw; } } return(retval); }