Tuesday, April 9, 2019

Change Route of Web Api

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using Vidhyalay_Online.Auth;
using Vidhyalay_Online.Models;

namespace Vidhyalay_Online.Controllers_Api
{
    [RoutePrefix("api/users")]
    public class FeeHeadListController : ApiController
    {
        private db_context db = new db_context();
        DataUtility du = new DataUtility();
        string sql = "";

        // GET: api/FeeHeadList
        [Route("data")]
        [HttpGet]
        public List<v_student_wise_fee_WMnCnP> get_feedetail([FromUri] v_student_wise_fee_WMnCnP d)
        {
            var data = from x in db.v_student_wise_fee_WMnCnP
                       where (d.ADM_NO == null || x.ADM_NO == d.ADM_NO)
                       && (d.STUDENTID == null || d.STUDENTID == x.STUDENTID)
                       orderby x.ACT_CODE
                       select x;
            List<v_student_wise_fee_WMnCnP> data_list = data.ToList();
            return data_list;
        }
        [Route("adm_no")]
        [HttpGet]
        public List<v_student_wise_fee_WMnCnP> get_feedetail(string adm_no)
        {
            var data = from x in db.v_student_wise_fee_WMnCnP
                       where (adm_no == null || x.ADM_NO == adm_no)                     
                       orderby x.ACT_CODE
                       select x;
            List<v_student_wise_fee_WMnCnP> data_list = data.ToList();
            return data_list;
        }

        [Route("data3")]
        [HttpGet]
        public List<v_student_wise_fee_WMnCnP> get_feedetail1([FromUri] v_student_wise_fee_WMnCnP d)
        {
            var data = from x in db.v_student_wise_fee_WMnCnP
                       where (d.ADM_NO == null || x.ADM_NO == d.ADM_NO)
                       && (d.STUDENTID == null || d.STUDENTID == x.STUDENTID)
                       orderby x.ACT_CODE
                       select x;
            List<v_student_wise_fee_WMnCnP> data_list = data.ToList();
            return data_list;
        }
       
    }
}

No comments:

Post a Comment

Linq Expression syntax for where condtion in linq

(Expression<Func<T, bool>> filter)