public BaseResponse <ServiceGroupModel> GetServiceGroup(int serviceGroupID)
        {
            BaseResponse <ServiceGroupModel> response = new BaseResponse <ServiceGroupModel>();
            var findItem = unitOfWork.GetRepository <DC_ServiceGroup>().dbSet.FirstOrDefault((q) => q.ServiceGroupID == serviceGroupID);

            if (findItem != null)
            {
                var serviceItemIds = findItem.DC_SerGrpSerIt.Select(it => it.ServiceItemID.Value).ToList();
                response.Data = Mapper.DynamicMap <ServiceGroupModel>(findItem);
                // 取出带总价
                IServiceItemService service = IOCContainer.Instance.Resolve <IServiceItemService>();
                var request = new BaseRequest <ServiceItemFilter>();
                request.Data.ServiceItemIds = serviceItemIds;
                var serviceItemResponse = service.QueryServiceItem(request);
                //response.Data.GroupItems = (List<ServiceItemModel>)serviceItemResponse.Data;
                // 取出数量
                var serviceItems = unitOfWork.GetRepository <DC_SerGrpSerIt>()
                                   .dbSet.Where(it => it.ServiceGroupID == response.Data.ServiceGroupID)
                                   .Select(it => new { it.ServiceTimes, it.ServiceItemID })
                                   .ToList();

                response.Data.GroupItems = new List <ServiceItemModel>();
                serviceItems.ForEach(it =>
                {
                    var subFindItem = serviceItemResponse.Data.FirstOrDefault(sub => sub.ServiceItemID == it.ServiceItemID);
                    if (subFindItem != null)
                    {
                        var newItem          = Mapper.DynamicMap <ServiceItemModel>(subFindItem);
                        newItem.ServiceTimes = it.ServiceTimes;
                        response.Data.GroupItems.Add(newItem);
                    }
                });
            }
            return(response);
        }
예제 #2
0
        public IHttpActionResult Query([FromBody] BaseRequest <ServiceItemFilter> request)
        {
            var response = service.QueryServiceItem(request);

            return(Ok(response));
        }