コード例 #1
0
        public HttpResponseMessage GetUserInstAnnoucementList(int page)
        {
            try
            {
                var      parameters = Request.GetQueryNameValuePairs();
                DateTime startTime  = DateTime.Now;
                if (!DateTime.TryParse(parameters.FirstOrDefault(p => p.Key == "StartTime").Value, out startTime))
                {
                    startTime = DateTime.Parse("2017-01-01");
                }
                DateTime endTime = DateTime.Now;
                if (!DateTime.TryParse(parameters.FirstOrDefault(p => p.Key == "EndTime").Value, out endTime))
                {
                    endTime = DateTime.Now;
                }

                var user = UserHelper.GetCurrentUser();
                Func <Announcement, bool> predicate = a => (a.PublishDate >= startTime) &&
                                                      (a.PublishDate <= endTime) &&
                                                      (a.InstituteId == user.InstId) &&
                                                      a.Status == "C" &&
                                                      (a.Type == "I");
                return(ResponseWrapper.SuccessResponse(repository.GetAnnoucementList(predicate, page)));
            }
            catch (Exception e)
            {
                return(ResponseWrapper.ExceptionResponse(e));
            }
        }