//Update a record public static int UpdateRecord(eCustomerPointsMap eobj) { using (OneFineRateEntities db = new OneFineRateEntities()) { try { OneFineRate.tblCustomerPointsMap obj = (OneFineRate.tblCustomerPointsMap)OneFineRateAppUtil.clsUtils.ConvertToObject(eobj, new OneFineRate.tblCustomerPointsMap()); db.tblCustomerPointsMaps.Attach(obj); db.Entry(obj).State = System.Data.Entity.EntityState.Modified; return(db.SaveChanges()); } catch (DbEntityValidationException e) { foreach (var eve in e.EntityValidationErrors) { foreach (var ve in eve.ValidationErrors) { Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); } } throw e; } catch (Exception ex) { throw ex; } } }
//Get Single Record public static eCustomerPointsMap GetRecordById(int id) { eCustomerPointsMap eobj = new eCustomerPointsMap(); using (OneFineRateEntities db = new OneFineRateEntities()) { var dbobj = db.tblCustomerPointsMaps.SingleOrDefault(u => u.iId == id); if (dbobj != null) { eobj = (eCustomerPointsMap)OneFineRateAppUtil.clsUtils.ConvertToObject(dbobj, eobj); } } return(eobj); }
//Add new record public static int AddRecord(eCustomerPointsMap customerPointsMap) { using (OneFineRateEntities db = new OneFineRateEntities()) { try { OneFineRate.tblCustomerPointsMap dbCustomerPoint = (OneFineRate.tblCustomerPointsMap)OneFineRateAppUtil.clsUtils.ConvertToObject(customerPointsMap, new OneFineRate.tblCustomerPointsMap()); db.tblCustomerPointsMaps.Add(dbCustomerPoint); return(db.SaveChanges()); } catch (Exception ex) { throw ex; } } }