/// <summary>
        /// 获取订单状态
        /// </summary>
        /// <param name="hospitalId">医院ID</param>
        /// <param name="vendorId"></param>
        /// <returns></returns>
        public JsonNetResult GetAuditingProducts(string hospitalId, string vendorId)
        {
            if (string.IsNullOrEmpty(hospitalId))
            {
                throw new Exception("The hospital id is empty.");
            }
            if (string.IsNullOrEmpty(vendorId))
            {
                throw new Exception("The vendor id is empty.");
            }

            try
            {
                var list           = new AuditingProductService().QueryLatestVesion(hospitalId, vendorId).ToDictionary(item => item.ProductId);
                var products       = new VendorProductService().QueryByVendor(vendorId);
                var productService = new ProductService();

                var result = new List <object>();
                foreach (var product in products)
                {
                    var productEntity = productService.Get(product.ProductId);
                    if (productEntity == null)
                    {
                        throw new Exception("The product does not exist.");
                    }

                    AuditingProductEntity auditEntity;
                    bool isAudit;
                    int  version;
                    if (list.TryGetValue(product.ProductId, out auditEntity))
                    {
                        isAudit = auditEntity.IsAudit;
                        version = auditEntity.Version;
                    }
                    else
                    {
                        isAudit = false;
                        version = 0;
                    }

                    result.Add(new
                    {
                        ProductId = product.ProductId,
                        VendorId  = vendorId,
                        Version   = version,
                        Name      = productEntity.Name,
                        IsAudit   = isAudit
                    });
                }


                return(JsonNet(new ResponseResult(true, result)));
            }
            catch (Exception e)
            {
                return(JsonNet(new ResponseResult(e)));
            }
        }
示例#2
0
        public JsonNetResult VendorProducts(string vendorId, DateTime applyTime)
        {
            var auditingList = new AuditingProductService().QueryValidVersion(this.UserContext.CurrentHospital, vendorId, applyTime);
            var products     = new ProductService().GetByVendor(vendorId);

            AuditingProductEntity auditing;
            var list = products.Select(item =>
            {
                return(new
                {
                    Id = item.Id,
                    Name = item.Name,
                    Description = item.Description,
                    ShortCode = item.ShortCode,
                    MeasuringUnit = item.MiniPackageUnit,
                    MiniPackageCount = item.MiniPackageCount,
                    MiniPackageCapacity = item.MiniPackageSpec,
                    Barcode = item.Barcode,
                    IsAuditing = auditingList.TryGetValue(item.Id, out auditing) ? auditing.IsAudit : false
                });
            });

            return(JsonNet(new ResponseResult(true, list)));
        }