コード例 #1
0
        public static bool ModifyChargingPile(ChargingPileEntity entity)
        {
            int result = 0;

            if (entity != null)
            {
                ChargeRepository mr = new ChargeRepository();

                ChargingPileInfo info = TranslateChargingPileEntity(entity);


                if (entity.ID > 0)
                {
                    result = mr.ModifyChargingPile(info);
                }
                else
                {
                    info.CreateDate = DateTime.Now;
                    result          = mr.CreateNewChargingPile(info);
                    if (result > 0)
                    {
                        ChargingBaseInfo cb = mr.GetChargingBaseById(info.ChargingBaseID);
                        if (cb != null)
                        {
                            int num = cb.ChargeNum + 1;
                            mr.ModifyPileNum(num, info.ChargingBaseID);
                        }
                    }
                }

                List <ChargingPileInfo> miList = mr.GetAllChargingPileInfo();//刷新缓存
                Cache.Add("ChargingPileALL", miList);
            }
            return(result > 0);
        }
コード例 #2
0
        public static int RemoveChargingPiple(long id)
        {
            ChargeRepository mr = new ChargeRepository();
            int r = mr.RemoveChargePile(id);
            List <ChargingPileInfo> miList = mr.GetAllChargingPileInfo();//刷新缓存

            Cache.Add("ChargingPileALL", miList);
            return(r);
        }
コード例 #3
0
        public static List <ChargingPileEntity> GetAllChargingPileEntity()
        {
            List <ChargingPileEntity> all    = new List <ChargingPileEntity>();
            ChargeRepository          mr     = new ChargeRepository();
            List <ChargingPileInfo>   miList = Cache.Get <List <ChargingPileInfo> >("ChargingPileALL");

            if (miList.IsEmpty())
            {
                miList = mr.GetAllChargingPileInfo();
                Cache.Add("ChargingPileALL", miList);
            }
            if (!miList.IsEmpty())
            {
                foreach (ChargingPileInfo mInfo in miList)
                {
                    ChargingPileEntity chargingPileEntity = TranslateChargingPileInfo(mInfo);
                    all.Add(chargingPileEntity);
                }
            }

            return(all);
        }