public GridWrap<dynamic> GetList([FromBody]Department value) { var r = new GridWrap<dynamic>(); try { using (var context = new GZJContext()) { var arr = from t in context.Departments select t; if (value != null) { if (value.CompanyId > 0) arr = from t in arr where t.CompanyId == value.CompanyId select t; } r.total = arr.Count(); r.success = true; arr.ToList() .ForEach(t => { r.rows.Add(t.DTO()); }); } } catch (Exception ex) { r.message = ex.Message; } return r; }
public GridWrap<dynamic> GetHouses([FromBody]JObject value) { var r = new GridWrap<dynamic>(); try { dynamic arg = value; if (null == arg) throw new Exception("未指定的参数"); int leaseholderid = 0; DateTime? enddate =null; DateTime _enddate=new DateTime(); foreach (JProperty prop in arg) { if (prop.Name == "leaseholderid") int.TryParse(prop.Value.ToString(), out leaseholderid); if(prop.Name=="enddate") { if (DateTime.TryParse(prop.Value.ToString(), out _enddate)) enddate = _enddate; } } using (var context = new GZJContext()) { var arr = from t in context.LeaseHistories select t; if (leaseholderid > 0) arr = from t in arr where t.LeaseHolderId == leaseholderid select t; if (enddate.HasValue) arr = from t in arr where t.EndDate.HasValue && t.EndDate <= enddate.Value select t; else arr = from t in arr where !t.EndDate.HasValue select t; arr = from t in arr orderby t.StartDate descending select t; r.total = arr.Count(); arr.ToList() .ForEach(t => { r.rows.Add(t.House.DTO()); }); } } catch (Exception ex) { r.message = ex.Message; } return r; }
public GridWrap<dynamic> GetLeaseHolders([FromBody]JObject value) { var r = new GridWrap<dynamic>(); try { dynamic arg = value; if (null == arg) throw new Exception("未指定的参数"); int houseid = 0; foreach (JProperty prop in arg) { if (prop.Name == "leaseholderid") int.TryParse(prop.Value.ToString(), out houseid); } using (var context = new GZJContext()) { var arr = from t in context.LeaseHistories select t; if (houseid > 0) arr = from t in arr where t.HouseId==houseid select t; r.total = arr.Count(); arr.ToList() .ForEach(t => { r.rows.Add(t.LeaseHolder.DTO()); }); } } catch (Exception ex) { r.message = ex.Message; } return r; }
public dynamic GetList([FromBody]JObject value) { GridWrap<dynamic> r = new GridWrap<dynamic>(); try { using (var context = new GZJContext()) { var arr = from t in context.Companies select t; r.total = arr.Count(); arr.ToList() .ForEach(t => { r.rows.Add(t.DTO()); }); r.success = true; } } catch (Exception ex) { r.message = ex.Message; } return r; }
public GridWrap<dynamic> GetDepartments([FromBody]Policy value) { var r = new GridWrap<dynamic>(); try { using (var context = new GZJContext()) { var s = context.Policies.SingleOrDefault(t => t.PolicyNo == value.PolicyNo); if (null == s) throw new Exception("权限数据为空"); var arr = from t in s.Departments select t; arr.ToList() .ForEach(t => { r.rows.Add(t.DTO()); r.total += 1; }); r.success = true; } } catch (Exception ex) { r.message = ex.Message; } return r; }
public GridWrap<dynamic> GetList([FromBody]JObject obj) { var r = new GridWrap<dynamic>(); try { dynamic arg = obj; if (null == arg) throw new Exception("未提交的参数"); int page = 0; int rows = 0; int neighborhoodid = 0; int categoryid = 0; bool? ismls = null; bool? islowincome = null; int total = 0; foreach (JProperty prop in arg) { if (prop.Name == "page") int.TryParse(prop.Value.ToString(), out page); if (prop.Name == "rows") int.TryParse(prop.Value.ToString(), out rows); if (prop.Name == "neighborhoodid") int.TryParse(prop.Value.ToString(), out neighborhoodid); if (prop.Name == "categoryid") int.TryParse(prop.Value.ToString(), out categoryid); if (prop.Name == "ismls") ismls = Convert.ToBoolean(prop.Value.ToString()); if (prop.Name == "islowincome") islowincome = Convert.ToBoolean(prop.Value.ToString()); } using (var context = new GZJContext()) { var arr = from t in context.Rents select t; total = arr.Count(); if (page > 0 && rows > 0) { arr = from t in arr orderby t.Id descending select t; arr = arr.Take(page * rows).Skip((page - 1) * rows); } arr.ToList() .ForEach(t => { r.rows.Add(t.DTO()); }); r.total = total; r.success = true; } } catch (Exception ex) { r.message = ex.Message; } return r; }
/*将家庭成员列表转换成DTO包裹对象*/ internal GridWrap<dynamic> ConvertToFamilyDTO() { var r = new GridWrap<dynamic>(); try { Families.ForEach(t => { r.rows.Add(t.DTO()); r.total += 1; }); r.success = true; } catch (Exception ex) { r.message = ex.Message; } return r; }
public GridWrap<dynamic> GetList([FromBody]JObject obj) { var list = new GridWrap<dynamic>(); try { dynamic arg = obj; if (arg == null) return list; string key = ""; int page = 0; int rows = 0; int categoryid = 0; int neighborhoodid=0; using (var context = new GZJContext()) { var arr = from t in context.Houses select t; foreach (JProperty prop in arg) { if (prop.Name == "key") key = prop.Value.ToString(); if (prop.Name == "neighborhoodid") int.TryParse(prop.Value.ToString(), out neighborhoodid); if (prop.Name == "categoryid") int.TryParse(prop.Value.ToString(), out categoryid); if (prop.Name == "page") int.TryParse(prop.Value.ToString(), out page); if (prop.Name == "rows") int.TryParse(prop.Value.ToString(), out rows); } if (key.Length > 0) arr = from t in arr where (t.HouseNo != null && t.HouseNo.Contains(key)) || (t.Memo != null && t.Memo.Contains(key)) || (t.Neighborhood != null && t.Neighborhood.NeighborhoodName.Contains(key)) || (t.Category != null && t.Category.CategoryName.Contains(key)) select t; if(categoryid>0) { //获取当前节点及子节点 var categoryids = HouseCategoryLogic.GetChildren(categoryid,context).Select(t => t.Id); arr = from t in arr where categoryids.Contains(t.CategoryId) ||t.CategoryId==categoryid select t; } if(neighborhoodid>0) { //获取区域 var neighborhoods = NeighborhoodLogic.GetChildren(neighborhoodid,context).Select(t => t.Id); arr = from t in arr where neighborhoods.Contains(t.NeighborhoodId) ||neighborhoodid==t.NeighborhoodId select t; } list.total = arr.Count(); if (page > 0 && rows > 0) { //必须调用orderby arr = from t in arr orderby t.HouseNo ascending select t; arr = arr.Take(page * rows).Skip((page - 1) * rows); } arr.ToList() .ForEach(t => { list.rows.Add(t.DTO()); }); } list.success = true; } catch (Exception ex) { list.message = ex.Message; } return list; }
public GridWrap<dynamic> GetList([FromBody]JObject filter) { var r = new GridWrap<dynamic>(); try { dynamic data = filter; if (data == null) throw new Exception("请提交查询参数"); string _startdate = data.startdate ?? ""; string _enddate = data.enddate ?? ""; string _key = data.key ?? ""; int page = Convert.ToInt32(data.page); int rows = Convert.ToInt32(data.rows); using (var context = new GZJContext()) { var arr = from t in context.Announces select t; if (_key.Length > 0) arr = from t in arr where t.Content.Contains(_key) || t.Title.Contains(_key) select t; DateTime dateStart; if (_startdate.Length > 0 && DateTime.TryParse(_startdate, out dateStart)) { arr = from t in arr where t.PubDate >= dateStart select t; } DateTime dateEnd; if (_enddate.Length > 0 && DateTime.TryParse(_enddate, out dateEnd)) { arr = from t in arr where t.PubDate <= dateEnd select t; } arr = from t in arr orderby t.PubDate descending select t; int total = arr.Count(); arr = arr.Take(page * rows).Skip(rows * (page - 1)); var _arr = from t in arr select new { id =t.Id, title = t.Title, pubdate =t.PubDate, pubusername = t.PubUser.UserName, smallcontent =t.Content == null ? "" :t.Content.Substring(0,20) }; r.rows.AddRange(_arr.ToList()); r.success = true; } } catch (Exception ex) { r.message = ex.Message; } return r; }
public GridWrap<dynamic> GetPolicies([FromBody]Department value) { var r = new GridWrap<dynamic>(); try { using (var context = new GZJContext()) { var d = context.Departments.SingleOrDefault(t => t.Id == value.Id); if (null == d) throw new Exception("岗位数据为空"); var arr = from t in d.Policies select t; arr.ToList() .ForEach(t => { r.rows.Add(t.DTO()); }); r.total = arr.Count(); r.success = true; } } catch (Exception ex) { r.message = ex.Message; } return r; }
public GridWrap<dynamic> GetList([FromBody]JObject obj) { var r = new GridWrap<dynamic>(); try { using(var context=new GZJContext()) { var arr = from t in context.Leaseholders select t; dynamic arg = obj; if (arg != null) { string key = arg.key ?? ""; if (key.Length > 0) arr = from t in arr where (t.Address != null && t.Address.Contains(key)) || (t.BusinessName != null && t.BusinessName.Contains(key)) || (t.CardNo != null && t.CardNo.Contains(key)) || (t.ContactPhone != null && t.ContactPhone.Contains(key)) || (t.Memo != null && t.Memo.Contains(key)) || (t.UserName.Contains(key)) select t; //房管员 string admin = arg.admin ?? ""; if(admin.Length>0) { var leaseholderids = (from t in context.LeaseHistories where t.House != null && t.House.AdminUserCode != null && t.House.AdminUserCode == admin && !t.EndDate.HasValue select t.LeaseHolderId).ToList(); arr = from t in arr where leaseholderids.Contains(t.Id) select t; } //房号 string houseno = arg.houseno ?? ""; if(houseno.Length>0) { var leaseholderids = (from t in context.LeaseHistories where t.House != null && t.House.HouseNo != null && t.House.HouseNo.Contains(houseno) && !t.EndDate.HasValue select t.LeaseHolderId).ToList(); arr = from t in arr where leaseholderids.Contains(t.Id) select t; } r.total = arr.Count(); //page,row int page = arg.page ?? 0; int rows = arg.rows ?? 0; if (page > 0 && rows > 0) { arr = from t in arr orderby t.CreatedDate descending select t; arr = arr.Take(page * rows).Skip((page - 1) * rows); } } else { r.total = arr.Count(); } arr.ToList() .ForEach(t => { r.rows.Add(t.DTO()); }); r.success = true; } } catch (Exception ex) { r.message = ex.Message; } return r; }
public Result GetLeaseInfo([FromBody]JObject value) { var r = new Result(); try { dynamic arg=value; if(arg==null) throw new Exception("未指定查询参数"); int leaseholderid=arg.leaseholderid; string _startdate=arg.startdate||""; string _enddate=arg.enddate||""; using (var context = new GZJContext()) { var s = context.Leaseholders.SingleOrDefault(t => t.Id ==leaseholderid); if (null == s) throw new Exception("承租人信息并不存在"); /*获取承租历史记录 1.有可能获取多套房源 */ DateTime startdate=DateTime.Now.Date; DateTime enddate=DateTime.MaxValue; if(_startdate.Length>0) startdate=Convert.ToDateTime(_startdate); if(_enddate.Length>0) enddate=Convert.ToDateTime(_enddate); var histories =new GridWrap<dynamic>(); s.LeaseHistories .Where(t=>t.StartDate<=startdate&&t.EndDate<=enddate) .ToList() .ForEach(t=>{ histories.total+=1; histories.rows.Add(new{ housestructurename=t.House.HouseStructure.HouseStructureName, buildingarea=t.House.BuildingArea, usablearea=t.House.UsableArea, standard=t.Rent.Standard, standardpermonth=t.Rent.Standard*(decimal)(t.House.UsableArea) }); }); histories.success=true; r.data = new { leaseholdername=s.UserName, cardno=s.CardNo, address=s.Address, businessname=s.BusinessName, leasehistories=histories }; r.success = true; } } catch (Exception ex) { r.message = ex.Message; } return r; }
public GridWrap<dynamic> GetList([FromBody]JObject value) { var r = new GridWrap<dynamic>(); try { using (var context = new GZJContext()) { var arr = from t in context.Users select t; dynamic arg = value; if (arg != null) { string key = arg.key ?? ""; if (key.Length > 0) arr = from t in arr where t.Memo != null && t.Memo.Contains(key) || t.UserName.Contains(key) || t.UserCode.Contains(key) select t; bool? isadmin = arg.isadmin; if (isadmin.HasValue) arr = from t in arr where t.IsAdmin == isadmin.Value select t; r.total = arr.Count(); arr.ToList() .ForEach(t => { r.rows.Add(t.DTO()); }); r.success = true; //TODO:正在做的 } } } catch (Exception ex) { r.message = ex.Message; } return r; }