码迷,mamicode.com
首页 > Windows程序 > 详细

WebApi

时间:2018-11-22 18:11:38      阅读:169      评论:0      收藏:0      [点我收藏+]

标签:splay   etc   nbsp   state   isp   获取   linq   log   eric   

技术分享图片
  1 using System;
  2 using System.Collections.Generic;
  3 using System.Linq;
  4 using System.Net;
  5 using System.Net.Http;
  6 using System.Web.Http;
  7 
  8 namespace VacationOA.API.Controllers
  9 {
 10     using BLL;
 11     using MODEL;
 12     public class VacationAPIController : ApiController
 13     {
 14         StaffBLL staffbll = new StaffBLL();
 15         LeaveBLL leaveBll = new LeaveBLL();
 16         CheckBLL checkbll = new CheckBLL();
 17         [Route("LoginStaff")]
 18         [HttpGet]
 19         public Staff LoginStaff(string name, string department)
 20         {
 21             return staffbll.LoginStaff(name, department);
 22         }
 23         /// <summary>
 24         /// 添加请假单
 25         /// </summary>
 26         /// <param name="l"></param>
 27         /// <returns></returns>
 28         [Route("AddLeave")]
 29         [HttpPost]
 30         public int AddLeave(Leave l)
 31         {
 32             //异常处理
 33             try
 34             {
 35                 return leaveBll.AddLeave(l);
 36             }
 37             catch (Exception ex)
 38             {
 39                 return 0;
 40             }
 41            
 42         }
 43         /// <summary>
 44         /// 修改请假单
 45         /// </summary>
 46         /// <param name="l"></param>
 47         /// <returns></returns>
 48 
 49         [Route("updateleave")]
 50         [HttpPost]
 51         public int updateleave(Leave l)
 52         {
 53             return leaveBll.updateleave(l);
 54         }
 55         /// <summary>
 56         /// 获取请假单
 57         /// </summary>
 58         /// <returns></returns>
 59         [Route("GetLeaves")]
 60        [HttpPost]
 61         public Paging GetLeaves(LikeShow ls)
 62         {
 63             Paging paging = new Paging();
 64             List<Leave> list1 = leaveBll.GetLeaves();
 65             list1 = list1.Where(n => n.staffID.Equals(ls.staffID)).ToList();
 66             if (ls.state != "" && ls.state != null)
 67             {
 68                 list1 = list1.Where(n=>n.state.Equals(ls.state)).ToList();
 69             }
 70             if (ls.starttime != null)
 71             {
 72                 list1 = list1.Where(n => n.startTime>=ls.starttime).ToList();
 73             }
 74             if (ls.endtiome != null)
 75             {
 76                 list1 = list1.Where(n => n.endTime<=ls.endtiome).ToList();
 77             }
 78             if (ls.Department!=null&&ls.Department!="")
 79             {
 80                 list1 = list1.Where(n => n.Department.Equals(ls.Department)).ToList();
 81             }
 82             paging.Currentpage = ls.Currentpage;
 83             paging.Totlepage = list1.Count / 3 + (list1.Count % 3==0?0:1);
 84             paging.RowCounts = list1.Count;
 85             paging.DataBox = list1.Skip((ls.Currentpage-1)*3).Take(3).ToList();
 86             return paging;
 87         }
 88         /// <summary>
 89         /// 获取请假单 我的审核列表
 90         /// </summary>
 91         /// <returns></returns>
 92         [Route("GetLeavesCheck")]
 93         [HttpPost]
 94         public Paging GetLeavesCheck(LikeShow ls)
 95         {
 96             Paging paging = new Paging();
 97             List<Leave> list1 = leaveBll.GetLeavesCheck();
 98             if (ls.starttime != null)
 99             {
100                 list1 = list1.Where(n => n.startTime >= ls.starttime).ToList();
101             }
102             if (ls.endtiome != null)
103             {
104                 list1 = list1.Where(n => n.endTime <= ls.endtiome).ToList();
105             }
106             if (ls.Department != null && ls.Department != "")
107             {
108                 list1 = list1.Where(n => n.Department.Equals(ls.Department)).ToList();
109             }
110             paging.Currentpage = ls.Currentpage;
111             paging.Totlepage = list1.Count / 3 + (list1.Count % 3 == 0 ? 0 : 1);
112             paging.RowCounts = list1.Count;
113             paging.DataBox = list1.Skip((ls.Currentpage - 1) * 3).Take(3).ToList();
114             return paging;
115         }
116         /// <summary>
117         /// 反填请假单
118         /// </summary>
119         [Route("GetleaveByID")]
120         [HttpGet]
121         public Leave GetleaveByID(int id)
122         {
123             List<Leave> list1 = leaveBll.GetLeaves();
124             return list1.Where(n=>n.leaveID.Equals(id)).FirstOrDefault();
125         }
126         /// <summary>
127         /// 根据假条id查询是否有关于这个假条审核通过的审核单
128         /// </summary>
129         /// <param name="id"></param>
130         /// <returns></returns>
131         [Route("GetCheckbyid")]
132         [HttpGet]
133         public int GetCheckbyid(int id)
134         {
135             return checkbll.GetCheckbyid(id);
136         }
137         /// <summary>
138         /// 添加审核清单
139         /// </summary>
140         /// <param name="tcheck"></param>
141         /// <returns></returns>
142         [Route("AddTcheck")]
143         [HttpPost]
144         public int AddTcheck(TCheck tcheck)
145         {
146             return checkbll.AddTcheck(tcheck);
147         }
148         /// <summary>
149         /// 修改请假单的状态,审核时间,说明,
150         /// </summary>
151         /// <param name="l"></param>
152         /// <returns></returns>
153         [Route("updateleaveState")]
154         [HttpGet]
155         public int updateleaveState(int id, DateTime checktime, string explain, string state)
156         {
157             return leaveBll.updateleaveState(id, checktime, explain, state);
158         }
159         /// <summary>
160         /// 根据id获取对应请假单的审核历史
161         /// </summary>
162         /// <returns></returns>
163         [Route("GetChecks")]
164         [HttpGet]
165         public List<TCheck> GetChecks(int id)
166         {
167             return checkbll.GetChecks(id);
168         }
169     }
170 }
VacationAPIController

 

WebApi

标签:splay   etc   nbsp   state   isp   获取   linq   log   eric   

原文地址:https://www.cnblogs.com/xcleowong/p/10002491.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!