예제 #1
0
        public static bool Update(ParkCarModel model)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }

            model.CarModelName = model.CarModelName.Trim();
            IParkCarModel factory  = ParkCarModelFactory.GetFactory();
            ParkCarModel  carModel = factory.QueryByRecordId(model.CarModelID);
            //if (carModel.IsDefault == YesOrNo.Yes && model.IsDefault == YesOrNo.No)
            //    throw new MyException("必须设置一个默认类型");

            List <ParkCarModel> carModels = factory.QueryByParkingId(model.PKID);

            if (carModels.Count(p => p.CarModelName == model.CarModelName && p.CarModelID != model.CarModelID) != 0)
            {
                throw new MyException("车型名称已存在,请更改名称");
            }

            bool result = factory.Update(model);

            if (result)
            {
                OperateLogServices.AddOperateLog <ParkCarModel>(model, OperateType.Update);
            }
            return(result);
        }
예제 #2
0
        public static ParkCarModel GetDefaultCarModel(string parkingid, out string errorMsg)
        {
            if (parkingid.IsEmpty())
            {
                throw new ArgumentNullException("parkingid");
            }

            IParkCarModel factory = ParkCarModelFactory.GetFactory();

            return(factory.GetDefaultCarModel(parkingid, out errorMsg));
        }
예제 #3
0
        public static List <ParkCarModel> QueryByParkingIds(List <string> parkingIds)
        {
            if (parkingIds == null || parkingIds.Count == 0)
            {
                throw new ArgumentNullException("parkingIds");
            }

            IParkCarModel factory = ParkCarModelFactory.GetFactory();

            return(factory.QueryByParkingIds(parkingIds));
        }
예제 #4
0
        public static List <ParkCarModel> QueryByParkingId(string parkingId)
        {
            if (string.IsNullOrWhiteSpace(parkingId))
            {
                throw new ArgumentNullException("parkingId");
            }

            IParkCarModel factory = ParkCarModelFactory.GetFactory();

            return(factory.QueryByParkingId(parkingId));
        }
예제 #5
0
        public static ParkCarModel QueryByRecordId(string recordId)
        {
            if (string.IsNullOrWhiteSpace(recordId))
            {
                throw new ArgumentNullException("recordId");
            }

            IParkCarModel factory = ParkCarModelFactory.GetFactory();

            return(factory.QueryByRecordId(recordId));
        }
예제 #6
0
        public static bool Delete(string recordId)
        {
            if (string.IsNullOrWhiteSpace(recordId))
            {
                throw new ArgumentNullException("recordId");
            }

            IParkCarModel factory = ParkCarModelFactory.GetFactory();
            bool          result  = factory.Delete(recordId);

            if (result)
            {
                OperateLogServices.AddOperateLog(OperateType.Delete, string.Format("recordId:{0}", recordId));
            }
            return(result);
        }
예제 #7
0
        public static bool Add(ParkCarModel model)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }

            model.CarModelName = model.CarModelName.Trim();
            model.CarModelID   = GuidGenerator.GetGuidString();
            IParkCarModel       factory   = ParkCarModelFactory.GetFactory();
            List <ParkCarModel> carModels = factory.QueryByParkingId(model.PKID);

            if (carModels.Count(p => p.CarModelName == model.CarModelName) != 0)
            {
                throw new MyException("车型名称已存在,请更改名称");
            }
            bool result = factory.Add(model);

            if (result)
            {
                OperateLogServices.AddOperateLog <ParkCarModel>(model, OperateType.Add);
            }
            return(result);
        }
예제 #8
0
        public static bool AddDefault(string parkingId, DbOperator dbOperator)
        {
            IParkCarModel factory = ParkCarModelFactory.GetFactory();

            return(factory.Add(GetDefaultParkCarModel(parkingId), dbOperator));
        }