public HttpResponseMessage getTasks(DTOFilterGetTasksRequest request) { using (var db = new KOCSAMADLSEntities(false)) { var filter = request.getFilter(); filter.fieldFilters.Add(new DTOFieldFilter { fieldName = "deleted", value = 0, op = 2 }); if (request.isTaskFilter()) { return(Request.CreateResponse(HttpStatusCode.OK, db.task.SqlQuery(filter.subTables["taskid"].getFilterSQL()) .OrderBy(t => t.taskname) .Select(t => new { t.taskid, t.taskname, t.tasktype }).ToList(), "application/json")); } if (request.isTaskstateFilter()) { var acik = new adsl_taskstatepool { taskstate = "AÇIK", taskstateid = 0 }; var query = filter.getFilterSQL(); var tspIds = db.taskstatematches.SqlQuery(query) .Select(t => t.stateid).ToList(); var res = db.taskstatepool.Where(tsp => tspIds.Contains(tsp.taskstateid)).OrderBy(tsp => tsp.taskstate).ToList(); res.Insert(0, acik); return(Request.CreateResponse(HttpStatusCode.OK, res.Select(r => r.toDTO()).ToList(), "application/json")); } if (request.isObjecttypeFilter()) { var objids = db.task.SqlQuery(filter.subTables["taskid"].getFilterSQL()).Select(s => s.attachableobjecttype).Distinct().ToList(); var res = db.objecttypes.Where(o => objids.Contains(o.typeid)) .OrderBy(t => t.typname) .ToList(); return(Request.CreateResponse(HttpStatusCode.OK, res.Select(s => new { s.typeid, s.typname }).ToList(), "application/json")); } if (request.isPersonelTypeFilter()) { var pids = db.task.SqlQuery(filter.subTables["taskid"].getFilterSQL()).Select(s => s.attachablepersoneltype).Distinct().ToList(); var res = db.objecttypes.Where(p => pids.Contains(p.typeid)).OrderBy(p => p.typname).ToList(); return(Request.CreateResponse(HttpStatusCode.OK, res.Select(t => new { t.typeid, t.typname }).ToList(), "application/json")); } return(Request.CreateResponse(HttpStatusCode.OK, db.tasktypes.SqlQuery(filter.subTables["tasktype"].getFilterSQL()) .Select(tt => new { tt.TaskTypeId, tt.TaskTypeName }) .OrderBy(tt => tt.TaskTypeName).ToList(), "application/json" )); } }
bool ITaskRequest.isTaskFilter() { return(taskRequest.isTaskFilter()); }