예제 #1
0
        //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);
        }
예제 #2
0
        //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);
        }
예제 #3
0
        //Get Single Record
        public static eChains GetSingleRecordById(int id)
        {
            eChains eobj = new eChains();

            using (OneFineRateEntities db = new OneFineRateEntities())
            {
                var dbobj = db.tblChainMs.SingleOrDefault(u => u.iChainID == id);
                if (dbobj != null)
                {
                    eobj = (eChains)OneFineRateAppUtil.clsUtils.ConvertToObject(dbobj, eobj);
                }
            }
            return(eobj);
        }