예제 #1
0
        /// <summary>
        /// 根据日期时间返回会议预定记录
        /// </summary>
        /// <returns>会议预定记录</returns>
        public List <MeetingDateGroupModel> GetMeetingListByDateTime(MeetingSearchModel model)
        {
            using (var dbcontext = new MissionskyOAEntities())
            {
                //查询
                var entity = dbcontext.MeetingCalendars.Where(it => it.MeetingRoomId == model.MeetingRoomId && it.StartDate >= model.StartDate.Date && it.StartDate <= model.EndDate.Date && it.Status == 1).GroupBy(x => x.StartDate).AsEnumerable().Select(group =>
                                                                                                                                                                                                                                                             new
                {
                    startdate = group.Key,
                    Meetings  = group.Where(it => it.Id != null).OrderBy(c => c.StartTime)
                });

                if (entity == null)
                {
                    throw new Exception("此日期段内无会议信息");
                }
                //根据日期group返回会议记录
                List <MeetingDateGroupModel> meetingList = new List <MeetingDateGroupModel>();
                entity.ToList().ForEach(item =>
                {
                    MeetingDateGroupModel temp = new MeetingDateGroupModel()
                    {
                        meetings = new List <MeetingCalendarModel>()
                    };
                    temp.startDate = item.startdate;
                    item.Meetings.ToList().ForEach(i =>
                    {
                        temp.meetings.Add(i.ToModel());
                    });
                    meetingList.Add(temp);
                });
                return(meetingList);
            }
        }
예제 #2
0
 /// <summary>
 /// 根据用户ID,日期时间返回会议预定记录
 /// </summary>
 /// <returns>会议预定记录</returns>
 public List <MeetingCalendarModel> GetUserReserveMeetingHistory(MeetingSearchModel model)
 {
     using (var dbcontext = new MissionskyOAEntities())
     {
         //查询
         var entity = dbcontext.MeetingCalendars.Where(it => it.ApplyUserId == model.UserId && it.StartDate >= model.StartDate.Date && it.StartDate <= model.EndDate.Date).OrderBy(item => item.StartDate).ThenBy(a => a.StartTime);
         //根据日期group返回会议记录
         List <MeetingCalendarModel> meetingList = new List <MeetingCalendarModel>();
         entity.ToList().ForEach(item =>
         {
             meetingList.Add(item.ToModel());
         });
         return(meetingList);
     }
 }
        public ApiListResponse <MeetingCalendarModel> GetUserReserveMeetingHistory(MeetingSearchModel model)
        {
            if (model == null)
            {
                throw new ApiBadRequestException("无效请求数据");
            }
            if (model.UserId == 0)
            {
                model.UserId = this.Member.Id;
            }
            if (model.StartDate > model.EndDate)
            {
                throw new ApiBadRequestException("开始日期必须小于结束日期");
            }
            ApiListResponse <MeetingCalendarModel> response = new ApiListResponse <MeetingCalendarModel>()
            {
                Result = this.MeetingService.GetUserReserveMeetingHistory(model)
            };

            return(response);
        }
        public ApiListResponse <MeetingDateGroupModel> GetMeetingListByDateTime(MeetingSearchModel model)
        {
            if (model == null)
            {
                throw new ApiBadRequestException("无效请求数据");
            }
            if (model.MeetingRoomId == 0)
            {
                throw new ApiBadRequestException("会议室ID不能为空");
            }
            if (model.StartDate > model.EndDate)
            {
                throw new ApiBadRequestException("开始日期必须小于结束日期");
            }
            ApiListResponse <MeetingDateGroupModel> response = new ApiListResponse <MeetingDateGroupModel>()
            {
                Result = this.MeetingService.GetMeetingListByDateTime(model)
            };

            return(response);
        }