using Aspose.Words.Lists; using BLL; using Model; using System; using System.Collections.Generic; using System.Linq; using System.Web.Http; namespace WebAPI.Controllers { /// /// /// public class ToDoItemController : ApiController { /// /// 根据projectId,userId获取待办事项 /// /// /// /// public Model.ResponeData getToDoItemByProjectIdUserId(string projectId, string userId) { var responeData = new Model.ResponeData(); try { using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) { var user = db.Sys_User.FirstOrDefault(x => x.UserId == userId); var person = db.SitePerson_Person.FirstOrDefault(x => x.ProjectId == projectId && x.IdentityCard == user.IdentityCard); var getDataList1 = db.Sp_APP_GetToDoItems(projectId, userId).ToList(); List getDataList = new List(); HashSet ids = new HashSet(); foreach (var item in getDataList1) { getDataList.Add(item); ids.Add(item.DataId); } if (person != null) { var getDataList2 = db.Sp_APP_GetToDoItems(projectId, person.PersonId).ToList(); foreach (var item in getDataList2) { if (!ids.Contains(item.DataId)) { getDataList.Add(item); } } } responeData.data = new { getDataList.Count, getDataList }; } } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } } }