public HttpResponseMessage getCSB(DTOFilterGetCSBRequest request) { using (var db = new CRMEntities()) { var filter = request.getFilter(); if (request.isCustomerFilter()) { return(Request.CreateResponse(HttpStatusCode.OK, db.customer.SqlQuery(filter.getFilterSQL()) .Where(r => r.deleted == false) .Select(r => new { r.customerid, r.customername, r.flat }) .ToList(), "application/json")); } else if (request.isBlockFilter()) { return(Request.CreateResponse(HttpStatusCode.OK, db.block.SqlQuery(filter.subTables["blockid"].getFilterSQL()) .Where(r => r.deleted == false) .Select(r => new { r.blockid, r.blockname, r.hp }) .OrderBy(r => r.blockname).ToList(), "application/json")); } else if (request.isSiteFilter()) { return(Request.CreateResponse(HttpStatusCode.OK, db.site.SqlQuery(filter.subTables["blockid"].subTables["siteid"].getFilterSQL()) .Where(r => r.deleted == false) .Select(r => new { r.siteid, r.sitename, r.siteaddress }).OrderBy(r => r.sitename).ToList() , "application/json")); } else if (request.isSitedistrictFilter()) { return(Request.CreateResponse(HttpStatusCode.OK, db.site.SqlQuery(filter.subTables["blockid"].subTables["siteid"].getFilterSQL()) .Where(r => r.deleted == false) .Select(r => new { r.sitedistrict }).Distinct().OrderBy(r => r.sitedistrict).ToList() , "application/json")); } return(Request.CreateResponse(HttpStatusCode.OK, db.site.SqlQuery(filter.subTables["blockid"].subTables["siteid"].getFilterSQL()) .Where(r => r.deleted == false) .Select(r => new { r.region }).Distinct().OrderBy(r => r.region).ToList() , "application/json")); } }
public bool isCustomerFilter() { return(csbRequest.isCustomerFilter()); }