コード例 #1
0
        public HttpResponseMessage GetInstitute([FromBody] InstituteSearchViewModel insdata)
        {
            IQueryable <SET_INSTITUTE> institutes = db.SET_INSTITUTE.AsQueryable();

            if (insdata.Institute_Type.HasValue)
            {
                institutes = institutes.Where(i => i.INST_TYPE_NO == insdata.Institute_Type);
            }

            if (!string.IsNullOrEmpty(insdata.Institute_Dbid))
            {
                institutes = institutes.Where(i => i.F_INSTITUTION_DB_ID == insdata.Institute_Dbid);
            }

            if (!string.IsNullOrEmpty(insdata.Institute_Name))
            {
                institutes = institutes.Where(i => i.INSTITUTE_NAME.ToLower()
                                              .Contains(insdata.Institute_Name.ToLower()));
            }

            if (!string.IsNullOrEmpty(insdata.Institute_Eiin))
            {
                institutes = institutes.Where(i => i.EIIN_NUMBER == insdata.Institute_Eiin);
            }

            if (insdata.THANA_NO.HasValue)
            {
                institutes = institutes.Where(i => i.THANA_NO == insdata.THANA_NO);
            }
            else if (insdata.ZILLA_NO.HasValue)
            {
                var thanalist = from thana in db.SET_THANA
                                where thana.ZILLA_NO == insdata.ZILLA_NO
                                select thana.THANA_NO;
                institutes = institutes.Where(i => thanalist.Contains(i.THANA_NO));
            }
            else if (insdata.DIVISION_NO.HasValue)
            {
                var zillalist = from zilla in db.SET_ZILLA
                                where zilla.DIVISION_NO == insdata.DIVISION_NO
                                select zilla.ZILLA_NO;

                var thanalist = from thana in db.SET_THANA
                                where zillalist.Contains(thana.ZILLA_NO)
                                select thana.THANA_NO;
                institutes = institutes.Where(i => thanalist.Contains(i.THANA_NO));
            }

            var result = institutes.Select(i => new {
                insno   = i.INSTITUTE_NO,
                instype = i.SET_INST_TYPE.INST_TYPE_NAME,
                insname = i.INSTITUTE_NAME,
                inseiin = i.EIIN_NUMBER,
                insdbid = i.F_INSTITUTION_DB_ID
            });

            return(Request.CreateResponse(HttpStatusCode.OK, result));
        }
コード例 #2
0
        public HttpResponseMessage GetAssignedInstitute([FromBody] InstituteSearchViewModel insdata)
        {
            //IQueryable<SET_INSTITUTE> institutes = db.SET_INSTITUTE.AsQueryable();

            ObjectResult <TPR_INSTITUTE_ASSIGNMENTS_GET_Result> institutes =
                db.TPR_INSTITUTE_ASSIGNMENTS_GET(insdata.PROJECT_NO, insdata.USER_NO, insdata.Institute_Name,
                                                 insdata.Institute_Code, insdata.THANA_NO, insdata.ZILLA_NO, insdata.DIVISION_NO);

            var result = institutes.Select(i => new
            {
                insno    = i.INSTITUTE_NO,
                insname  = i.INSTITUTE_NAME,
                inseiin  = i.EIIN_NUMBER,
                insdbid  = i.F_INSTITUTION_DB_ID,
                thana    = i.THANA_NAME,
                zilla    = i.ZILLA_NAME,
                division = i.DIVISION_NAME
            });

            return(Request.CreateResponse(HttpStatusCode.OK, result));
        }