예제 #1
0
        //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;
                }
            }
        }
예제 #2
0
 //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;
         }
     }
 }
예제 #3
0
        //Update a record
        public static int UpdateLoyalityPointsExpiryDate(eLoyalityPointsCustomerData eobj)
        {
            int retval = 0;

            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;
                    db.SaveChanges();
                    retval = 1;
                }
                catch (Exception)
                {
                    throw;
                }
            }
            return(retval);
        }