示例#1
0
        /// <summary>
        /// 搜索物品信息
        /// </summary>
        /// <param name="webModel">列表页视图Model</param>
        /// <param name="context">数据库连接上下文对象</param>
        /// <returns></returns>
        public async Task <GoodsViewModel> SearchGoodsAsync(GoodsViewModel webModel, ApplicationDbContext context)
        {
            try
            {
                //Source Data List
                var list = await AdmissionRepository.GetListAsync(webModel, context);

                //Return Data List
                var dataList = new List <GoodsData>();

                if (list != null && list.Any())
                {
                    dataList.AddRange(list.Select(item => new GoodsData
                    {
                        Id          = item.Id.ToString(),
                        Name        = item.Name,
                        IsEnabled   = item.IsEnabled,
                        Size        = item.Size,
                        ImageSrc    = item.ImageSrc,
                        Description = !string.IsNullOrEmpty(item.Description) && item.Description.Length > 20 ? item.Description.Substring(0, 20) + "..." : item.Description
                    }));
                }

                webModel.GoodsList = dataList;
                webModel.Total     = await AdmissionRepository.GetListCountAsync(webModel, context);
            }
            catch (Exception ex)
            {
                _logger.LogError("获取物品信息列表失败:{0},\r\n内部错误信息:{1}", ex.Message, ex.InnerException.Message);
            }
            return(webModel);
        }
示例#2
0
        /// <summary>
        /// 搜索提问信息
        /// </summary>
        /// <param name="webModel"></param>
        /// <param name="context"></param>
        /// <returns></returns>
        public async Task <QuestionViewModel> SearchQuestionAsync(QuestionViewModel webModel, ApplicationDbContext context)
        {
            try
            {
                //Source Data List
                var list = await AdmissionRepository.GetListAsync(webModel, context);

                //Return Data List
                var dataList = new List <QuestionData>();

                if (list != null && list.Any())
                {
                    dataList.AddRange(list.Select(item => new QuestionData
                    {
                        Id       = item.Id.ToString(),
                        Name     = item.StuName,
                        AskFor   = item.AskForName,
                        DateTime = item.AskTime.ToString("yyyy-MM-dd HH:mm"),
                        IsReply  = item.IsReply,
                        Content  = !string.IsNullOrEmpty(item.Content) && item.Content.Length > 20 ? item.Content.Substring(0, 20) + "..." : item.Content
                    }));
                }

                webModel.QuestionList = dataList;
                webModel.Total        = await AdmissionRepository.GetListCountAsync(webModel, context);
            }
            catch (Exception ex)
            {
                _logger.LogError("获取提问信息列表失败:{0},\r\n内部错误信息:{1}", ex.Message, ex.InnerException.Message);
            }
            return(webModel);
        }
示例#3
0
        /// <summary>
        /// 搜索迎新服务信息
        /// </summary>
        /// <param name="webModel">列表页视图Model</param>
        /// <param name="context">数据库连接上下文对象</param>
        /// <returns></returns>
        public async Task <ServiceViewModel> SearchServiceAsync(ServiceViewModel webModel, ApplicationDbContext context)
        {
            try
            {
                //Source Data List
                var list = await AdmissionRepository.GetListAsync(webModel, context);

                //Return Data List
                var dataList = new List <ServiceData>();

                if (list != null && list.Any())
                {
                    dataList.AddRange(list.Select(item => new ServiceData
                    {
                        Id            = item.Id.ToString(),
                        Name          = item.Name,
                        Address       = item.Address,
                        IsEnabled     = item.IsEnabled,
                        StartDateTime = item.StartTime.ToString("yyyy-MM-dd HH:mm"),
                        EndDateTime   = item.EndTime.ToString("yyyy-MM-dd HH:mm"),
                        Description   = !string.IsNullOrEmpty(item.Description) && item.Description.Length > 15 ? item.Description.Substring(0, 15) + "..." : item.Description
                    }));
                }

                webModel.ServiceList = dataList;
                webModel.Total       = await AdmissionRepository.GetListCountAsync(webModel, context);
            }
            catch (Exception ex)
            {
                _logger.LogError("获取迎新服务列表失败:{0},\r\n内部错误信息:{1}", ex.Message, ex.InnerException.Message);
            }
            return(webModel);
        }