Пример #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 QueryByRecordId(string recordId)
        {
            if (string.IsNullOrWhiteSpace(recordId))
            {
                throw new ArgumentNullException("recordId");
            }

            IParkCarModel factory = ParkCarModelFactory.GetFactory();

            return(factory.QueryByRecordId(recordId));
        }