Beispiel #1
0
        public IWsModel <ReqCar, List <ResBrand> > BrandHot([FromBody] WsModel <ReqCar, List <ResBrand> > model)
        {
            if (model == null)
            {
                return(new WsModel <ReqCar, List <ResBrand> >().Fail(ErrorCode.PARAM_NULL, "参数为空"));
            }
            if (model.Request == null)
            {
                return(model.Fail(ErrorCode.PARAM_NULL, "参数为空"));
            }
            var pageParam = new PageParam(model.Request.PageSize);
            var ret       = new DBsCar().GetBrandHot(ValidityState.Enabled, pageParam);

            if (ret == null)
            {
                return(model.Fail(ErrorCode.DB_NOTEXISTED, "数据不存在"));
            }
            var result = new List <ResBrand>();

            foreach (var item in ret)
            {
                result.Add(new ResBrand(item));
            }
            return(model.Ok(result));
        }
Beispiel #2
0
        public IWsModel <ReqAddSeries, ResBrand> AddCarSeries([FromBody] WsModel <ReqAddSeries, ResBrand> model)
        {
            if (model == null)
            {
                return(new WsModel <ReqAddSeries, ResBrand>().Fail(ErrorCode.PARAM_NULL, "参数为空"));
            }
            if (model.Request == null)
            {
                return(model.Fail(ErrorCode.PARAM_NULL, "参数为空"));
            }
            if (!model.Request.Valid4Enum())
            {
                return(model.Fail(ErrorCode.PARAM_INVALID, "枚举参数无效"));
            }
            if (!model.Request.Valid4AddSeries())
            {
                return(model.Fail(ErrorCode.PARAM_INVALID, "参数无效"));
            }
            var dbscar = new DBsCar();

            if (dbscar.GetBrandSeriesDetail(model.Request.ParentId, ValidityState.Enabled) == null)
            {
                return(model.Fail(ErrorCode.PARAM_INVALID, "参数ParentId无效"));
            }
            var carBrand  = new CarsBrandSeries(model.Request.ParentId, model.Request.Name, ValidityState.Enabled, model.Request.SeriesGrade);
            var retDetail = new DBaCar().AddBrandSeries(carBrand);

            if (retDetail == 0)
            {
                return(model.Fail(ErrorCode.DB_SAVE_FAILED, "添加失败"));
            }
            var ret = new ResBrand(carBrand);

            return(model.Ok(ret));
        }
Beispiel #3
0
        public IWsModel <ReqCar, List <ResCarConciseInfo> > BeforeUserCars([FromBody] WsModel <ReqCar, List <ResCarConciseInfo> > model)
        {
            if (model == null)
            {
                return(new WsModel <ReqCar, List <ResCarConciseInfo> >().Fail(ErrorCode.PARAM_NULL, "参数为空"));
            }
            if (model.Request == null)
            {
                return(model.Fail(ErrorCode.PARAM_NULL, "参数为空"));
            }
            if (string.IsNullOrWhiteSpace(model.Request.IndexCarId))
            {
                return(model.Fail(ErrorCode.PARAM_NULL, "参数IndexCarId为空"));
            }
            if (string.IsNullOrWhiteSpace(model.Request.OpenId))
            {
                return(model.Fail(ErrorCode.PARAM_NULL, "参数OpenId为空"));
            }
            var pageParam = new PageParam(model.Request.PageSize, model.Request.SortType, model.Request.Ascending);
            var ret       = new DBsCar().GetBeforeUserCars(model.Request.OpenId, model.Request.CarSell, pageParam, model.Request.IndexCarId);

            if (ret == null)
            {
                return(model.Fail(ErrorCode.DB_NOTEXISTED, "数据不存在"));
            }
            return(model.Ok(ret));
        }
Beispiel #4
0
        public IWsModel <ReqCar, List <ResBrand> > BrandSeries([FromBody] WsModel <ReqCar, List <ResBrand> > model)
        {
            if (model == null)
            {
                return(new WsModel <ReqCar, List <ResBrand> >().Fail(ErrorCode.PARAM_NULL, "参数为空"));
            }
            if (model.Request == null)
            {
                return(model.Fail(ErrorCode.PARAM_NULL, "参数为空"));
            }
            if (string.IsNullOrWhiteSpace(model.Request.BrandId))
            {
                return(model.Fail(ErrorCode.PARAM_NULL, "参数BrandId为空"));
            }
            var ret = new DBsCar().GetBrandSeries(model.Request.BrandId, ValidityState.Enabled);

            if (ret == null)
            {
                return(model.Fail(ErrorCode.DB_NOTEXISTED, "数据不存在"));
            }
            var result = new List <ResBrand>();

            foreach (var item in ret)
            {
                result.Add(new ResBrand(item));
            }
            return(model.Ok(result));
        }
Beispiel #5
0
        public IHttpActionResult pick(int id)
        {
            WsModel <string, customer> model = new WsModel <string, customer>();

            model.Response = DB.customers.SingleOrDefault(c => c.id == id);
            return(Ok(model));
        }
Beispiel #6
0
        public IWsModel <ReqAddBrand, ResBrand> AddCarBrand([FromBody] WsModel <ReqAddBrand, ResBrand> model)
        {
            if (model == null)
            {
                return(new WsModel <ReqAddBrand, ResBrand>().Fail(ErrorCode.PARAM_NULL, "参数为空"));
            }
            if (model.Request == null)
            {
                return(model.Fail(ErrorCode.PARAM_NULL, "参数为空"));
            }
            if (!model.Request.Valid4Enum())
            {
                return(model.Fail(ErrorCode.PARAM_INVALID, "枚举参数无效"));
            }
            if (!model.Request.Valid4AddBrand())
            {
                return(model.Fail(ErrorCode.PARAM_INVALID, "参数无效"));
            }
            var carBrand  = new CarsBrandSeries(model.Request.Name, model.Request.Capital, model.Request.BrandLogo, ValidityState.Enabled, model.Request.BrandType, model.Request.BrandCountry);
            var retDetail = new DBaCar().AddBrandSeries(carBrand);

            if (retDetail == 0)
            {
                return(model.Fail(ErrorCode.DB_SAVE_FAILED, "添加失败"));
            }
            var ret = new ResBrand(carBrand);

            return(model.Ok(ret));
        }
Beispiel #7
0
        public IWsModel <ReqAccount, ResAccount> AccountSimple([FromBody] WsModel <ReqAccount, ResAccount> model)
        {
            if (model == null)
            {
                return(new WsModel <ReqAccount, ResAccount>().Fail(ErrorCode.PARAM_NULL, "参数为空"));
            }
            if (model.Request == null)
            {
                return(model.Fail(ErrorCode.PARAM_NULL, "参数为空"));
            }
            if (string.IsNullOrWhiteSpace(model.Request.OpenId))
            {
                return(model.Fail(ErrorCode.PARAM_NULL, "参数OpenId为空"));
            }
            // var  wxlog=  WxLogFactory.GetWxLogger(typeof(QueryAccountService));
            //Account account = new DbsAccount().ById(model.Request.AccountId);
            Account account = new DbsAccount().ByOpenId(model.Request.OpenId, ValidityState.Enabled);

            if (account == null)
            {
                return(model.Fail(ErrorCode.DB_NOTEXISTED, "用户不存在"));
            }
            LogDebug($"找到用户{account.Name}");
            LogInfo($"找到用户{account.Name}");
            LogError($"找到用户{account.Name}");
            var res = new ResAccount(account);

            return(model.Ok(res));
        }
Beispiel #8
0
        public IWsModel <ReqCar, List <ResGroupBrand> > BrandAll([FromBody] WsModel <ReqCar, List <ResGroupBrand> > model)
        {
            if (model == null)
            {
                return(new WsModel <ReqCar, List <ResGroupBrand> >().Fail(ErrorCode.PARAM_NULL, "参数为空"));
            }
            if (model.Request == null)
            {
                return(model.Fail(ErrorCode.PARAM_NULL, "参数为空"));
            }
            // var ret = new DBsCar().GetAllBrand(ValidityState.Enabled);

            var ret = new DBsCar().GetGroupBrand(ValidityState.Enabled);

            if (ret == null || ret.Count(i => i != null) == 0)
            {
                return(model.Fail(ErrorCode.DB_NOTEXISTED, "品牌分组不存在"));
            }
            foreach (var item in ret)
            {
                var list = new DBsCar().GetGroupBrandList(ValidityState.Enabled, item.Capital);
                if (ret != null && ret.Count(i => i != null) > 0)
                {
                    item.Values = list;
                }
            }
            return(model.Ok(ret));
        }
Beispiel #9
0
        public IWsModel <ReqAddAccount, ResAccount> UpdateAccount([FromBody] WsModel <ReqAddAccount, ResAccount> model)
        {
            if (model == null)
            {
                return(new WsModel <ReqAddAccount, ResAccount>().Fail(ErrorCode.PARAM_NULL, "参数为空"));
            }
            if (model.Request == null)
            {
                return(model.Fail(ErrorCode.PARAM_NULL, "参数为空"));
            }
            if (string.IsNullOrWhiteSpace(model.Request.OpenId))
            {
                return(model.Fail(ErrorCode.PARAM_NULL, "参数为空"));
            }
            var retAccount = new DbsAccount().GetAccount(model.Request.OpenId);

            if (retAccount == null)
            {
                return(model.Fail(ErrorCode.DB_NOTEXISTED, "数据不存在"));
            }
            if (AlterModel(ref retAccount, model.Request))
            {
                var result = new DbaAccount().UpdateAccount(retAccount);
                if (result == 0)
                {
                    return(model.Fail(ErrorCode.DB_SAVE_FAILED, "修改失败"));
                }
            }
            var ret = new ResAccount(retAccount);

            return(model.Ok(ret));
        }
Beispiel #10
0
        public IWsModel <ReqCar, List <ResCarConciseInfo> > BeforeTodayCars([FromBody] WsModel <ReqCar, List <ResCarConciseInfo> > model)
        {
            if (model == null)
            {
                return(new WsModel <ReqCar, List <ResCarConciseInfo> >().Fail(ErrorCode.PARAM_NULL, "参数为空"));
            }
            if (model.Request == null)
            {
                return(model.Fail(ErrorCode.PARAM_NULL, "参数为空"));
            }
            if (string.IsNullOrWhiteSpace(model.Request.IndexCarId))
            {
                return(model.Fail(ErrorCode.PARAM_NULL, "参数IndexCarId为空"));
            }
            var begintime = DateTime.Today;
            var endtime   = DateTime.Today.AddDays(1).AddSeconds(-1);
            var pageParam = new PageParam(model.Request.PageSize, begintime, endtime);
            var ret       = new DBsCar().GetBeforeTodayCars(pageParam, model.Request.IndexCarId);

            if (ret == null)
            {
                return(model.Fail(ErrorCode.DB_NOTEXISTED, "数据不存在"));
            }
            return(model.Ok(ret));
        }
Beispiel #11
0
        public IWsModel <ReqAddCorporation, ResCorporation> AddCorporation([FromBody] WsModel <ReqAddCorporation, ResCorporation> model)
        {
            if (model == null)
            {
                return(new WsModel <ReqAddCorporation, ResCorporation>().Fail(ErrorCode.PARAM_NULL, "参数为空"));
            }
            if (model.Request == null)
            {
                return(model.Fail(ErrorCode.PARAM_NULL, "参数为空"));
            }
            if (!model.Request.Valid4AddCorporation())
            {
                return(model.Fail(ErrorCode.PARAM_NULL, "参数为空"));
            }
            if (new DbsAccount().GetCorporationInfoByName(model.Request.Name) != null)
            {
                return(model.Fail(ErrorCode.DB_EXISTED, "数据已存在"));
            }
            var corporation = new Corporation(model.Request.Name, model.Request.Address, model.Request.Presentation, model.Request.FixPhone, model.Request.Image, ValidityState.Disabled, DateTime.Now);
            var result      = new DbaAccount().AddCorporation(corporation);

            if (result == 0)
            {
                return(model.Fail(ErrorCode.DB_SAVE_FAILED, "添加失败"));
            }
            var ret = new ResCorporation(corporation);

            return(model.Ok(ret));
        }
Beispiel #12
0
 public IHttpActionResult save(WsModel <customer, com_result> model)
 {
     DB.customers.RemoveAll(c => c.id == model.Request.id);
     DB.customers.Add(model.Request);
     model.Response = new com_result();
     return(Ok(model));
 }
Beispiel #13
0
        public IWsModel <ReqAddCorporation, ResCorporation> UpdateCorporation([FromBody] WsModel <ReqAddCorporation, ResCorporation> model)
        {
            if (model == null)
            {
                return(new WsModel <ReqAddCorporation, ResCorporation>().Fail(ErrorCode.PARAM_NULL, "参数为空"));
            }
            if (model.Request == null)
            {
                return(model.Fail(ErrorCode.PARAM_NULL, "参数为空"));
            }
            if (string.IsNullOrWhiteSpace(model.Request.CorporationId))
            {
                return(model.Fail(ErrorCode.PARAM_NULL, "参数为空"));
            }
            var retCorporation = new DbsAccount().GetCorporationInfo(model.Request.CorporationId);

            if (retCorporation == null)
            {
                return(model.Fail(ErrorCode.DB_NOTEXISTED, "数据不存在"));
            }
            if (AlterModel(ref retCorporation, model.Request))
            {
                var result = new DbaAccount().UpdateCorporation(retCorporation);
                if (result == 0)
                {
                    return(model.Fail(ErrorCode.DB_SAVE_FAILED, "修改失败"));
                }
            }

            var ret = new ResCorporation(retCorporation);

            return(model.Ok(ret));
        }
Beispiel #14
0
        public IWsModel <ReqAddCar, ResCarConciseInfo> AddCarInfo([FromBody] WsModel <ReqAddCar, ResCarConciseInfo> model)
        {
            if (model == null)
            {
                return(new WsModel <ReqAddCar, ResCarConciseInfo>().Fail(ErrorCode.PARAM_NULL, "参数为空"));
            }
            if (model.Request == null)
            {
                return(model.Fail(ErrorCode.PARAM_NULL, "参数为空"));
            }
            if (!model.Request.Valid4Enum())
            {
                return(model.Fail(ErrorCode.PARAM_INVALID, "枚举参数无效"));
            }
            if (!model.Request.Valid4AddCar())
            {
                return(model.Fail(ErrorCode.PARAM_INVALID, "参数无效"));
            }
            var dbscar = new DBsCar();

            if (dbscar.GetBrandSeriesDetail(model.Request.BrandId, ValidityState.Enabled) == null)
            {
                return(model.Fail(ErrorCode.PARAM_INVALID, "参数BrandId无效"));
            }
            if (dbscar.GetBrandSeriesDetail(model.Request.SeriesId, ValidityState.Enabled) == null)
            {
                return(model.Fail(ErrorCode.PARAM_INVALID, "参数SeriesId无效"));
            }
            var dbsaccount = new DbsAccount();

            if (dbsaccount.ByOpenId(model.Request.AccountId, ValidityState.Enabled) == null)
            {
                return(model.Fail(ErrorCode.PARAM_INVALID, "参数AccountId无效"));
            }
            if (dbsaccount.GetCorporationInfo(model.Request.CorporationId, ValidityState.Enabled) == null)
            {
                return(model.Fail(ErrorCode.PARAM_INVALID, "参数CorporationId无效"));
            }
            var carDetail = new CarsDetails(model.Request.CarDrive, model.Request.CarEnergy, model.Request.CarGearbox, model.Request.CarSeat,
                                            model.Request.CarEmissionStandard, model.Request.Appearance, model.Request.Interior, model.Request.CarConfig, model.Request.CarLicenseTime, model.Request.CarAge,
                                            model.Request.Mileage, model.Request.Emission, model.Request.Images);
            var retDetail = new DBaCar().AddCarDetail(carDetail);

            if (retDetail == 0)
            {
                return(model.Fail(ErrorCode.DB_SAVE_FAILED, "添加失败"));
            }
            var carConcise = new CarsConcise(model.Request.AccountId, carDetail.Id, model.Request.CorporationId, model.Request.Name, model.Request.BrandId, model.Request.SeriesId, model.Request.GuidePrice,
                                             model.Request.SellingPrice, model.Request.BasePrice, ValidityState.Enabled, (carDetail.Images == null)?"":carDetail.Images[0], CarSell.Sale, model.Request.CarActivity);
            var retConcise = new DBaCar().AddCarConcise(carConcise);

            if (retConcise == 0)
            {
                return(model.Fail(ErrorCode.DB_SAVE_FAILED, "添加失败"));
            }
            var ret = new ResCarConciseInfo(carConcise, carDetail.CarLicenseTime, carDetail.Mileage);

            return(model.Ok(ret));
        }
Beispiel #15
0
        public IHttpActionResult update(WsModel <request_update, com_result> model)
        {
            var cust = DB.customers.SingleOrDefault(c => c.id == model.Request.id);

            cust.name      = model.Request.name;
            model.Response = new com_result();
            return(Ok(model));
        }
Beispiel #16
0
        public IHttpActionResult newone(string name)
        {
            WsModel <string, response_list> model = HttpContext.Current.Base().ApiModel <string, response_list>(name);
            response_list res = new response_list();

            res.list       = DB.customers.Where(c => c.name == name).ToArray();
            res.count      = res.list.Length;
            model.Response = res;
            return(Ok(model));
        }
Beispiel #17
0
        public IHttpActionResult querybyname(WsModel <string, response_list> model)
        {
            request_update req = new request_update();
            WsModel <request_update, com_result> r = HttpContext.Current.Base(model.User).ApiInvoke <icustomer, request_update, com_result>(i => i.update, req);
            response_list lst = new response_list();

            lst.list       = DB.customers.Where(c => c.name == model.Request).ToArray();
            lst.count      = lst.list.Count();
            model.Response = lst;
            return(Ok(model));
        }
Beispiel #18
0
        public IHttpActionResult query(int id, string name)
        {
            response_list res = new response_list();

            res.list  = DB.customers.Where(c => c.id == id || c.name == name).ToArray();
            res.count = res.list.Length;
            WsModel <string, response_list> model = HttpContext.Current.Base().ApiModel <string, response_list>(null);

            model.Response = res;
            return(Ok(model));
        }
Beispiel #19
0
        public IHttpActionResult list()
        {
            response_list res = new response_list();

            res.list  = DB.customers.ToArray();
            res.count = res.list.Length;
            HttpContext.Current.Base().ApiModel();
            WsModel <string, response_list> model = HttpContext.Current.Base().ApiModel <string, response_list>(null);

            model.Response = res;
            return(Ok(model));
        }
Beispiel #20
0
        public IWsModel <ReqAddCar, ResCarConciseInfo> UpdateCarInfo([FromBody] WsModel <ReqAddCar, ResCarConciseInfo> model)
        {
            if (model == null)
            {
                return(new WsModel <ReqAddCar, ResCarConciseInfo>().Fail(ErrorCode.PARAM_NULL, "参数为空"));
            }
            if (model.Request == null)
            {
                return(model.Fail(ErrorCode.PARAM_NULL, "参数为空"));
            }
            if (!model.Request.Valid4Enum())
            {
                return(model.Fail(ErrorCode.PARAM_INVALID, "枚举参数无效"));
            }
            if (string.IsNullOrWhiteSpace(model.Request.CarInfoId))
            {
                return(model.Fail(ErrorCode.PARAM_NULL, "参数为空"));
            }
            var carconcise = new DBsCar().GetCarInfo(model.Request.CarInfoId, ValidityState.Enabled);

            if (carconcise == null)
            {
                return(model.Fail(ErrorCode.DB_NOTEXISTED, "数据不存在"));
            }
            var cardetail = new DBsCar().GetCarDetail(carconcise.CarsDetailsId);

            if (carconcise == null)
            {
                return(model.Fail(ErrorCode.DB_NOTEXISTED, "数据不存在"));
            }
            if (AlterModel(ref cardetail, model.Request))
            {
                var retDetail = new DBaCar().UpdateCarDetail(cardetail);
                if (retDetail == 0)
                {
                    return(model.Fail(ErrorCode.DB_SAVE_FAILED, "修改失败"));
                }
            }
            if (AlterModel(ref carconcise, model.Request))
            {
                var retConcise = new DBaCar().UpdateCarConcise(carconcise);
                if (retConcise == 0)
                {
                    return(model.Fail(ErrorCode.DB_SAVE_FAILED, "修改失败"));
                }
            }
            var ret = new ResCarConciseInfo(carconcise, cardetail.CarLicenseTime, cardetail.Mileage);

            return(model.Ok(ret));
        }
Beispiel #21
0
        public IWsModel <ReqAccount, ResToken> Login([FromBody] WsModel <ReqAccount, ResToken> model)
        {
            if (model == null)
            {
                return(new WsModel <ReqAccount, ResToken>().Fail(ErrorCode.PARAM_NULL, "参数为空"));
            }
            if (model.Request == null)
            {
                return(model.Fail(ErrorCode.PARAM_NULL, "参数为空"));
            }
            if (model.Request.Valid4Login())
            {
                return(model.Fail(ErrorCode.PARAM_INVALID, "参数无效"));
            }
            var wechat = new WeChatService().GetOpenIdSeeeionKey(model.Request.Code);

            if (wechat == null)
            {
                return(model.Fail(ErrorCode.DB_NOTEXISTED, "Code错误"));
            }
            var account = new DbsAccount().GetAccount(wechat.openid);

            if (account == null)
            {
                var addaccount = new Account(model.Request.WechatName, wechat.openid, wechat.session_key, model.Request.Sex, ValidityState.Enabled, Identity.Visitor, model.Request.Logo, DateTime.Now);
                var addret     = new DbaAccount().AddAccount(addaccount);
                if (addret == 0)
                {
                    return(model.Fail(ErrorCode.DB_SAVE_FAILED, "添加失败"));
                }
                else
                {
                    var token = new WeChatService().GetToken(wechat);
                    var ret   = new ResToken(token, addaccount.OpenId);
                    return(model.Ok(ret));
                }
            }
            else
            {
                if (account.State != ValidityState.Enabled)
                {
                    return(model.Fail(ErrorCode.USER_DISABLE, "账户不可用"));
                }
                var token = new WeChatService().GetToken(wechat);
                var ret   = new ResToken(token, account.OpenId, account.Corporation);
                return(model.Ok(ret));
            }
        }
Beispiel #22
0
        public IWsModel <ReqCar, List <ResCarConciseInfo> > LaterFilterCars([FromBody] WsModel <ReqCar, List <ResCarConciseInfo> > model)
        {
            if (model == null)
            {
                return(new WsModel <ReqCar, List <ResCarConciseInfo> >().Fail(ErrorCode.PARAM_NULL, "参数为空"));
            }
            if (model.Request == null)
            {
                return(model.Fail(ErrorCode.PARAM_NULL, "参数为空"));
            }
            var pageParam = new PageParam(model.Request.PageSize, model.Request.SortType, model.Request.Ascending);
            var ret       = new DBsCar().GetLaterFilterCars(pageParam, model.Request.IndexCarId, model.Request.BrandId, model.Request.SeriesId, model.Request.CarActivity,
                                                            model.Request.SeriesGrade, model.Request.BrandCountry, model.Request.CarDrive, model.Request.CarEnergy, model.Request.CarGearbox, model.Request.CarSeat);

            if (ret == null)
            {
                return(model.Fail(ErrorCode.DB_NOTEXISTED, "数据不存在"));
            }
            return(model.Ok(ret));
        }
Beispiel #23
0
        public IWsModel <ReqAccount, ResCorporation> Corporation([FromBody] WsModel <ReqAccount, ResCorporation> model)
        {
            if (model == null)
            {
                return(new WsModel <ReqAccount, ResCorporation>().Fail(ErrorCode.PARAM_NULL, "参数为空"));
            }
            if (model.Request == null)
            {
                return(model.Fail(ErrorCode.PARAM_NULL, "参数为空"));
            }
            if (string.IsNullOrWhiteSpace(model.Request.OpenId))
            {
                return(model.Fail(ErrorCode.PARAM_NULL, "参数OpenId为空"));
            }
            var ret = new DbsAccount().GetCorporation(model.Request.OpenId, ValidityState.Enabled);

            if (ret == null)
            {
                return(model.Fail(ErrorCode.DB_NOTEXISTED, "公司不存在"));
            }
            return(model.Ok(ret));
        }
Beispiel #24
0
        public static List <WsFile> GetAllFilesFromWs(WsModel wsModel)
        {
            List <WsFile> wsFiles = new List <WsFile>();

            WsFldr wsFldr = new WsFldr();

            wsFldr.WsFldrs = wsModel.WsFldrs;

            WsUtility.GetWsFiles(item =>
            {
                if (item.WsFiles != null && item.WsFiles.Count > 0)
                {
                    foreach (var wsFile in item.WsFiles)
                    {
                        //if (wsFile.IsIncludedInClosure)
                        wsFiles.Add(wsFile);
                    }
                }
            }, wsFldr);

            return(wsFiles);
        }
Beispiel #25
0
        public IWsModel <ReqCar, ResCarDetail> CarInfo([FromBody] WsModel <ReqCar, ResCarDetail> model)
        {
            if (model == null)
            {
                return(new WsModel <ReqCar, ResCarDetail>().Fail(ErrorCode.PARAM_NULL, "参数为空"));
            }
            if (model.Request == null)
            {
                return(model.Fail(ErrorCode.PARAM_NULL, "参数为空"));
            }
            if (string.IsNullOrWhiteSpace(model.Request.CarId))
            {
                return(model.Fail(ErrorCode.PARAM_NULL, "参数CarId为空"));
            }
            var ret = new DBsCar().GetCarDetailToRes(model.Request.CarId);

            if (ret == null)
            {
                return(model.Fail(ErrorCode.DB_NOTEXISTED, "数据不存在"));
            }
            return(model.Ok(ret));
        }
Beispiel #26
0
        public IWsModel <ReqAddAccount, ResAccount> AddAccount([FromBody] WsModel <ReqAddAccount, ResAccount> model)
        {
            if (model == null)
            {
                return(new WsModel <ReqAddAccount, ResAccount>().Fail(ErrorCode.PARAM_NULL, "参数为空"));
            }
            if (model.Request == null)
            {
                return(model.Fail(ErrorCode.PARAM_NULL, "参数为空"));
            }
            if (!model.Request.Valid4AddAccount())
            {
                return(model.Fail(ErrorCode.PARAM_NULL, "参数为空"));
            }
            var dbs = new DbsAccount();

            if (dbs.GetAccount(model.Request.OpenId) != null)
            {
                return(model.Fail(ErrorCode.DB_EXISTED, "数据已存在"));
            }
            //验证公司是否存在
            if (dbs.GetCorporationInfo(model.Request.Corporation, ValidityState.Enabled) == null)
            {
                return(model.Fail(ErrorCode.DB_NOTEXISTED, "公司不存在"));
            }
            var account = new Account(model.Request.Wechat, model.Request.WechatName, model.Request.OpenId, model.Request.Corporation, model.Request.Sex, model.Request.Email, model.Request.Phone, model.Request.Name, ValidityState.Disabled, Identity.Staff, model.Request.Logo, DateTime.Now);
            var result  = new DbaAccount().AddAccount(account);

            if (result == 0)
            {
                return(model.Fail(ErrorCode.DB_SAVE_FAILED, "添加失败"));
            }
            var ret = new ResAccount(account);

            return(model.Ok(ret));
        }
Beispiel #27
0
        public IWsModel <ReqAccount, ResAccount> AccountInfo([FromBody] WsModel <ReqAccount, ResAccount> model)
        {
            if (model == null)
            {
                return(new WsModel <ReqAccount, ResAccount>().Fail(ErrorCode.PARAM_NULL, "参数为空"));
            }
            if (model.Request == null)
            {
                return(model.Fail(ErrorCode.PARAM_NULL, "参数为空"));
            }
            if (string.IsNullOrWhiteSpace(model.Request.OpenId))
            {
                return(model.Fail(ErrorCode.PARAM_NULL, "参数OpenId为空"));
            }
            var result = new DbsAccount().GetAccountInfo(model.Request.OpenId, ValidityState.Enabled);

            if (result == null)
            {
                return(model.Fail(ErrorCode.DB_NOTEXISTED, "用户不存在"));
            }
            result.DescIdentity = result.Identity.GetIdentityDescription();
            result.DescSex      = result.Sex.GetGenderDescription();
            return(model.Ok(result));
        }
Beispiel #28
0
        public IWsModel <ReqAddSeries, ResBrand> UpdateCarSeries([FromBody] WsModel <ReqAddSeries, ResBrand> model)
        {
            if (model == null)
            {
                return(new WsModel <ReqAddSeries, ResBrand>().Fail(ErrorCode.PARAM_NULL, "参数为空"));
            }
            if (model.Request == null)
            {
                return(model.Fail(ErrorCode.PARAM_NULL, "参数为空"));
            }
            if (!model.Request.Valid4Enum())
            {
                return(model.Fail(ErrorCode.PARAM_INVALID, "枚举参数无效"));
            }
            if (string.IsNullOrWhiteSpace(model.Request.CarSeriesId))
            {
                return(model.Fail(ErrorCode.PARAM_NULL, "参数为空"));
            }
            var carSeries = new DBsCar().GetBrandSeriesDetail(model.Request.CarSeriesId);

            if (carSeries == null)
            {
                return(model.Fail(ErrorCode.DB_NOTEXISTED, "数据不存在"));
            }
            if (AlterModel(ref carSeries, model.Request))
            {
                var retDetail = new DBaCar().UpdateBrandSeries(carSeries);
                if (retDetail == 0)
                {
                    return(model.Fail(ErrorCode.DB_SAVE_FAILED, "修改失败"));
                }
            }
            var ret = new ResBrand(carSeries);

            return(model.Ok(ret));
        }
Beispiel #29
0
 public IWsModel <ReqAccount, ResToken> Login([FromBody] WsModel <ReqAccount, ResToken> model)
 {
     return(_srv_queryaccount.Login(model));
 }
Beispiel #30
0
 public IWsModel <ReqAccount, ResCorporation> CorporationInfo([FromBody] WsModel <ReqAccount, ResCorporation> model)
 {
     return(_srv_queryaccount.CorporationInfo(model));
 }