using System.Collections.Generic; using System.Configuration; using System.Linq; using System.Web.Mvc; using DSWeb.Areas.Dispatch.DB; using DSWeb.Areas.Dispatch.Helper; using DSWeb.Areas.Dispatch.Models; using DSWeb.Dispatch.DAL; namespace DSWeb.Areas.Dispatch.Controllers { public class CommonController : Controller { private CommonDataContext commonDataContext = new CommonDataContext(); public JsonResult SearchDeptForCRM(string term) { var list = commonDataContext.SysDepts.Where(d => d.DEPTNO.IndexOf(term) > -1 || d.DEPTNAME.IndexOf(term) > -1).ToList(); return Json(list.Select(d => new { value = d.DEPTNAME, id = d.GID }).ToList(), JsonRequestBehavior.AllowGet); } public JsonResult SearchUserForCRM(string term) { var list = commonDataContext.Users.Where(u => u.SHOWNAME.IndexOf(term) > -1 || u.CODENAME.IndexOf(term) > -1).ToList(); return Json(list.Select(u => new { value = u.SHOWNAME, id = u.GID }).ToList(), JsonRequestBehavior.AllowGet); } public JsonResult GetInfoClientShortNames() { CommonDataContext dataContext = new CommonDataContext(); var list = dataContext.InfoClients.Select(i => i.SHORTNAME).ToList(); return Json(list, JsonRequestBehavior.AllowGet); } #region 筛选委托单位 [HttpGet] public JsonResult GetControllerInfoClients(string keyword) { List list = null; if (string.IsNullOrWhiteSpace(keyword)) { list = commonDataContext.InfoClients.Where(c => c.ISCONTROLLER == true).ToList(); } else { list = commonDataContext.InfoClients.Where(c => c.ISCONTROLLER == true && (c.CODENAME.StartsWith(keyword) || c.SHORTNAME.IndexOf(keyword) > -1)).ToList(); } return Json(new { value = list.AsInfoClientTruckViewModelList() }, JsonRequestBehavior.AllowGet); } #endregion } }