/// <summary>
        /// 获取关注记录
        /// </summary>
        /// <param name="AttentionQueryModel"></param>
        /// <returns></returns>
        public PageModel <Attention> GetAttentions(AttentionQuery AttentionQueryModel)
        {
            IQueryable <Attention> AttentionShop = from item in base.context.Attention
                                                   where item.UserId == AttentionQueryModel.UserId.Value
                                                   select item;

            if (!string.IsNullOrWhiteSpace(AttentionQueryModel.beginTime))
            {
                DateTime dt;
                if (DateTime.TryParse(AttentionQueryModel.beginTime, out dt))
                {
                    DateTime value = DateTime.Parse(AttentionQueryModel.beginTime);
                    AttentionShop =
                        from d in AttentionShop
                        where d.CreatDate >= value
                        select d;
                }
            }
            //end time
            if (!string.IsNullOrWhiteSpace(AttentionQueryModel.endTime))
            {
                DateTime dt;
                if (DateTime.TryParse(AttentionQueryModel.endTime, out dt))
                {
                    DateTime value = DateTime.Parse(AttentionQueryModel.endTime);
                    AttentionShop =
                        from d in AttentionShop
                        where d.CreatDate <= value
                        select d;
                }
            }
            if (!string.IsNullOrEmpty(AttentionQueryModel.productName))
            {
                AttentionShop =
                    from item in AttentionShop
                    where item.ProductName.Contains(AttentionQueryModel.productName)
                    select item;
            }
            if (!string.IsNullOrEmpty(AttentionQueryModel.compamyName))
            {
                AttentionShop =
                    from item in AttentionShop
                    where item.CompanyName.Contains(AttentionQueryModel.compamyName)
                    select item;
            }
            if (!string.IsNullOrEmpty(AttentionQueryModel.userName))
            {
                AttentionShop =
                    from item in AttentionShop
                    where item.UserName.Contains(AttentionQueryModel.userName)
                    select item;
            }
            Func <IQueryable <Attention>, IOrderedQueryable <Attention> > func = null;

            func = (IQueryable <Attention> d) =>
                   from o in d
                   orderby o.CreatDate descending
                   select o;
            int num = AttentionShop.Count();

            AttentionShop = AttentionShop.GetPage(out num, AttentionQueryModel.PageNo, AttentionQueryModel.PageSize, func);
            foreach (Attention list in AttentionShop.ToList())
            {
                ShopInfo shopInfo = context.ShopInfo.FirstOrDefault((ShopInfo m) => m.Id.Equals(list.ShopId));
                if (shopInfo != null)
                {
                    list.CompanyName = shopInfo.ShopName;
                }
                UserMemberInfo UserInfo = context.UserMemberInfo.FirstOrDefault((UserMemberInfo m) => m.Id.Equals(list.UserId) && m.UserType == 3);
                if (UserInfo != null)
                {
                    list.UserName = UserInfo.UserName;
                }
                ProductInfo productInfo = context.ProductInfo.FirstOrDefault((ProductInfo m) => m.Id.Equals(list.ProductId));
                if (productInfo != null)
                {
                    list.ProductName         = (productInfo == null ? "" : productInfo.ProductName);
                    list.ImagePath           = (productInfo == null ? "" : productInfo.ImagePath);
                    list.MarketPrice         = productInfo.MarketPrice;
                    list.MinSalePrice        = productInfo.MinSalePrice;
                    list.MeasureUnit         = productInfo.MeasureUnit;
                    list.EProductName        = productInfo.EProductName;
                    list.Purity              = productInfo.Purity;
                    list.CASNo               = productInfo.CASNo;
                    list.HSCODE              = productInfo.HSCODE;
                    list.DangerLevel         = productInfo.DangerLevel;
                    list.MolecularFormula    = productInfo.MolecularFormula;
                    list.MolecularWeight     = productInfo.MolecularWeight;
                    list.PASNo               = productInfo.PASNo;
                    list.LogP                = productInfo.LogP;
                    list.Shape               = productInfo.Shape;
                    list.Density             = productInfo.Density;
                    list.FusingPoint         = productInfo.FusingPoint;
                    list.BoilingPoint        = productInfo.BoilingPoint;
                    list.RefractiveIndex     = productInfo.RefractiveIndex;
                    list.StorageConditions   = productInfo.StorageConditions;
                    list.VapourPressure      = productInfo.VapourPressure;
                    list.PackagingLevel      = productInfo.PackagingLevel;
                    list.SafetyInstructions  = productInfo.SafetyInstructions;
                    list.DangerousMark       = productInfo.DangerousMark;
                    list.RiskCategoryCode    = productInfo.RiskCategoryCode;
                    list.TransportationNmber = productInfo.TransportationNmber;
                    list.RETCS               = productInfo.RETCS;
                    list.WGKGermany          = productInfo.WGKGermany;
                    list.SyntheticRoute      = productInfo.SyntheticRoute;
                    list.RelatedProducts     = productInfo.RelatedProducts;
                    list.MSDS                = productInfo.MSDS;
                    list.NMRSpectrum         = productInfo.NMRSpectrum;
                    list.RefuseReason        = productInfo.RefuseReason;
                    list.STRUCTURE_2D        = productInfo.STRUCTURE_2D;
                }
            }
            return(new PageModel <Attention>()
            {
                Models = AttentionShop,
                Total = num
            });
        }
Exemple #2
0
        public JsonResult List(string starttime, string endtime, string productName, string userName, int rows, int page, string companyName) //string companyName,
        {
            AttentionQuery AttentionQueryModel = new AttentionQuery()
            {
                ShopId      = base.CurrentSellerManager.ShopId,
                beginTime   = starttime,
                endTime     = endtime,
                userName    = userName,
                productName = productName,
                compamyName = companyName,
                PageSize    = rows,
                PageNo      = page,
            };
            PageModel <Attention>        AttentionShops = ServiceHelper.Create <IAttentionService>().SupplierGetAttentions(AttentionQueryModel);
            IEnumerable <AttentionModel> array          =
                from m in AttentionShops.Models.ToArray()
                select new AttentionModel()
            {
                Id                  = m.Id,
                UserId              = m.UserId,
                ShopId              = m.ShopId,
                ProductId           = m.ProductId,
                CreatDate           = m.CreatDate,
                ProductName         = m.ProductName,
                ImagePath           = m.ImagePath,
                MarketPrice         = m.MarketPrice,
                MinSalePrice        = m.MinSalePrice,
                MeasureUnit         = m.MeasureUnit,
                EProductName        = m.EProductName,
                Purity              = m.Purity,
                CASNo               = m.CASNo,
                HSCODE              = m.HSCODE,
                DangerLevel         = m.DangerLevel,
                MolecularFormula    = m.MolecularFormula,
                MolecularWeight     = m.MolecularWeight,
                PASNo               = m.PASNo,
                LogP                = m.LogP,
                Shape               = m.Shape,
                Density             = m.Density,
                FusingPoint         = m.FusingPoint,
                BoilingPoint        = m.BoilingPoint,
                RefractiveIndex     = m.RefractiveIndex,
                StorageConditions   = m.StorageConditions,
                VapourPressure      = m.VapourPressure,
                PackagingLevel      = m.PackagingLevel,
                SafetyInstructions  = m.SafetyInstructions,
                DangerousMark       = m.DangerousMark,
                RiskCategoryCode    = m.RiskCategoryCode,
                TransportationNmber = m.TransportationNmber,
                RETCS               = m.RETCS,
                WGKGermany          = m.WGKGermany,
                SyntheticRoute      = m.SyntheticRoute,
                RelatedProducts     = m.RelatedProducts,
                MSDS                = m.MSDS,
                NMRSpectrum         = m.NMRSpectrum,
                RefuseReason        = m.RefuseReason,
                STRUCTURE_2D        = m.STRUCTURE_2D,
                UserName            = m.UserName,
                CompanyName         = m.CompanyName
            };
            DataGridModel <AttentionModel> dataGridModel = new DataGridModel <AttentionModel>()
            {
                rows  = array,
                total = AttentionShops.Total
            };

            return(Json(dataGridModel));
        }