コード例 #1
0
        public IQueryable <LostThingsRecord> SearchRecords(SearchLostThingsParameter sp)
        {
            var query = context.LostThingsRecord.Where(x => x.ThingCatId == sp.ThingCatId &&
                                                       sp.FoundDateBeginUnix <= x.FoundTime &&
                                                       x.FoundTime <= sp.FoundDateEndUnix);

            if (sp.ThingDetailId != null)
            {
                query = query.Where(x => x.ThingDetailId == sp.ThingDetailId);
            }
            string SchoolIdPrefix = sp.SchoolId + "-";

            query = query.Where(x => x.FoundAddress.StartsWith(SchoolIdPrefix));
            if (sp.SchoolBuildingId != null)
            {
                query = query.Where(x => x.FoundAddress == (sp.SchoolId + "-" + sp.SchoolBuildingId).ToString());
            }
            switch (sp.ItemStatus)
            {
            case 1:
                query = query.Where(x => x.Isgiven == 0);
                break;

            case 2:
                query = query.Where(x => x.Isgiven == 1);
                break;

            case 3:
                break;

            default:
                break;
            }
            switch (sp.SortType)
            {
            case 0:
                query = query.OrderByDescending(x => x.PublishTime);
                break;

            case 1:
                query = query.OrderByDescending(x => x.FoundTime);
                break;

            default:
                query = query.OrderByDescending(x => x.PublishTime);
                break;
            }
            return(query);
        }
コード例 #2
0
 public JsonResult SearchLostThingRecords([FromBody] SearchLostThingsParameter sp)
 {
     return(new JsonResult(thingServices.SearchLostThingRecords(sp)));
 }
コード例 #3
0
 public IQueryable <LostThingsRecord> SearchLostThingRecords(SearchLostThingsParameter sp)
 {
     return(thing.SearchRecords(sp));
 }