コード例 #1
0
        // GET: api/IssueViews
        public IHttpActionResult GetIssueViews()
        {
            var    paras    = ControllerContext.Request.GetQueryNameValuePairs();
            string process  = paras.Where(c => c.Key == "process").FirstOrDefault().Value;
            string alias    = paras.Where(c => c.Key == "alias").FirstOrDefault().Value;
            string pageStr  = paras.Where(c => c.Key == "page").FirstOrDefault().Value;
            string limitStr = paras.Where(c => c.Key == "limit").FirstOrDefault().Value;

            MoonCakeCodeSampleEntities context = new MoonCakeCodeSampleEntities();
            var           result = context.getIssueView(alias, process).ToList();
            IssuePageView view   = new IssuePageView();

            view.Total = result.Count();

            int page  = Convert.ToInt32(pageStr);
            int limit = Convert.ToInt32(limitStr);

            if (page != 0 || limit != 0)
            {
                page   = page == 0 ? 1 : page;
                result = result.Skip((page - 1) * limit).Take(limit).ToList();
            }
            view.Views = result;
            return(Ok(view));
        }
コード例 #2
0
 public BasicCRUD()
 {
     context = new MoonCakeCodeSampleEntities();
 }
コード例 #3
0
        // GET api/<controller>/5

        public Product Get(int id)
        {
            MoonCakeCodeSampleEntities context = new MoonCakeCodeSampleEntities();

            return(context.Products.Where(c => c.id == id).FirstOrDefault());
        }
コード例 #4
0
        // GET api/<controller>
        public IEnumerable <Product> Get()
        {
            MoonCakeCodeSampleEntities context = new MoonCakeCodeSampleEntities();

            return(context.Products);
        }