public ActionResult Oil(string code) { if (string.IsNullOrEmpty(code)) { return(Redirect(OAuth2Api.GetCode(_corpId, AbsoluteUri(), "STATE", _agentId))); } string workerCn = null; try { var accessToken = AccessTokenContainer.GetToken(_corpId, _secret); GetUserInfoResult userInfo = OAuth2Api.GetUserId(accessToken, code); workerCn = userInfo.UserId; } catch { Logger.Error("微信授权错误"); } if (workerCn == null) { return(Content("系统取不到你的微信标识号")); } //workerCn = "90005"; var worker = WorkManager.GetWorkerByCn(workerCn); if (!worker.WorkRoleNames.Contains("司机")) { return(Content("需要司机角色")); } var depot = WorkManager.GetDepot(worker.DepotId); var vm = new OilViewModel(); vm.WorkerId = worker.Id; foreach (var v in _vehicleCache.GetList().FindAll(x => x.DepotId == depot.Id)) { vm.Vehicles.Add(new ComboItemModel() { Id = v.Id, Name = v.Cn + v.License }); } foreach (var v in _gasStationCache.GetList().FindAll(x => string.IsNullOrEmpty(x.DepotList) || x.DepotList.Contains(depot.Name))) { vm.GasStations.Add(new ComboItemModel() { Id = v.Id, Name = v.Name }); } foreach (var t in _oilTypeCache.GetList()) { vm.OilTypes.Add(new ComboItemModel() { Id = t.Id, Name = t.Name }); } return(View(vm)); }
public Task <List <ComboboxItemDto> > GetComboItems(string typeName) { var lst = new List <ComboboxItemDto>(); switch (typeName) { case "ArticleType": foreach (ArticleType t in _articleTypeCache.GetList()) { lst.Add(new ComboboxItemDto { Value = t.Id.ToString(), DisplayText = string.Format("{0} {1}", t.Cn, t.Name) }); } break; case "Post": foreach (Post t in _postCache.GetList()) { lst.Add(new ComboboxItemDto { Value = t.Id.ToString(), DisplayText = t.Name }); } break; case "RouteType": foreach (RouteType t in _routeTypeCache.GetList()) { lst.Add(new ComboboxItemDto { Value = t.Id.ToString(), DisplayText = t.Name }); } break; case "TaskType": foreach (TaskType t in _taskTypeCache.GetList()) { lst.Add(new ComboboxItemDto { Value = t.Id.ToString(), DisplayText = t.Name }); } break; case "TaskTypeFee": foreach (TaskType t in _taskTypeCache.GetList().FindAll(x => x.isTemporary == true)) { lst.Add(new ComboboxItemDto { Value = t.Id.ToString(), DisplayText = t.Name }); } break; case "WorkRole": foreach (WorkRole t in _workRoleCache.GetList()) { lst.Add(new ComboboxItemDto { Value = t.Id.ToString(), DisplayText = t.Name }); } break; case "AskOpenStyle": foreach (string t in _askOpenStyleItems) { lst.Add(new ComboboxItemDto { Value = t, DisplayText = t }); } break; case "BindStyle": foreach (string t in _bindStyleItems) { lst.Add(new ComboboxItemDto { Value = t, DisplayText = t }); } break; case "Sex": foreach (string t in _sexItems) { lst.Add(new ComboboxItemDto { Value = t, DisplayText = t }); } break; case "PoliticalStatus": foreach (string t in _politicalStatusItems) { lst.Add(new ComboboxItemDto { Value = t, DisplayText = t }); } break; case "Education": foreach (string t in _educationItems) { lst.Add(new ComboboxItemDto { Value = t, DisplayText = t }); } break; case "MaritalStatus": foreach (string t in _maritalStatusItems) { lst.Add(new ComboboxItemDto { Value = t, DisplayText = t }); } break; case "LicenseType": foreach (string t in _licenseTypeItems) { lst.Add(new ComboboxItemDto { Value = t, DisplayText = t }); } break; case "Status": foreach (string t in _statusItems) { lst.Add(new ComboboxItemDto { Value = t, DisplayText = t }); } break; case "ProcessStyle": foreach (string t in _processStyleItems) { lst.Add(new ComboboxItemDto { Value = t, DisplayText = t }); } break; case "Category": foreach (string t in _categoryItems) { lst.Add(new ComboboxItemDto { Value = t, DisplayText = t }); } break; case "OilType": foreach (var t in _oilTypeCache.GetList()) { lst.Add(new ComboboxItemDto { Value = t.Id.ToString(), DisplayText = t.Name }); } break; case "VehicleMTType": foreach (var t in _vehicleMTTypeCache.GetList()) { lst.Add(new ComboboxItemDto { Value = t.Id.ToString(), DisplayText = t.Name }); } break; default: break; } return(Task.FromResult <List <ComboboxItemDto> >(lst)); }