public ActionResult UrunDetayliIncele(Guid id) { ProductManager productManager = new ProductManager(); Product urun = productManager.UrunGetir(id); int commentCount = urun.ProductComment.Count; for (int i = 0; i < urun.ProductComment.Count; i++) { commentCount = commentCount + urun.ProductComment[i].ProductCommentReply.Count(); } SocialShareManager socialShareManager = new SocialShareManager(); List <SocialShare> urunPaylasimi = socialShareManager.UrunPaylasimlariniGetir(id); OylamaManager oylamaMnager = new OylamaManager(); int urunluOylamalarCount = oylamaMnager.UrunluOylamalariGetir(id).Count(); int facebookShareCount = urunPaylasimi.Where(x => x.SocialName == "facebook").Count(); int instagramShareCount = urunPaylasimi.Where(x => x.SocialName == "instagram").Count(); int twitterShareCount = urunPaylasimi.Where(x => x.SocialName == "twitter").Count(); int votedressShareCount = urunPaylasimi.Where(x => x.SocialName == "votedress").Count(); var JsonModel = new { urun = new { id = urun.id, productName = urun.ProductName, productImage = urun.ProductImage, Collections = urun.ProductCollection.Select(k => new { id = k.Collection.id, collectionName = k.Collection.CollectionName, description = k.Collection.Description, createDate = k.Collection.CreateDate, }), price = urun.Price, shortDescription = urun.ShortDescription, longDescription = urun.LongDescription, uploadDate = urun.UploadDate, detail = urun.ProductSize.Select(k => new { productSize = k.Size, productColors = k.ProductColor.Select(y => new { id = y.id, stockCount = y.StockCount, color = y.ProductColorDetail.Select(u => new { colorName = u.Color.ColorName, colorCode = u.Color.ColorCode, }), productImageGallery = y.ProdutImageGallery.Select(u => new { id = u.id, imagePath = u.ImagePath }) }), }), urunSosyalGucu = new { facebookShareCount = facebookShareCount, instagramShareCount = instagramShareCount, twitterShareCount = twitterShareCount, votedressShareCount = votedressShareCount, urunluOylamalarCount = urunluOylamalarCount, commentCount = commentCount }, comments = urun.ProductComment.OrderBy(x => x.CommentDate).Select(x => new { commentId = x.id, commentOwnerId = x.VotedressUser.id, commentOwnerFullName = x.VotedressUser.UserDetail.Name + " " + x.VotedressUser.UserDetail.SurName, commentOwnerProfilImage = x.VotedressUser.ProfileImage, comment = x.Comment, commentDate = x.CommentDate, commentLikes = x.ProductCommentLike.Select(t => new { LikedFullName = t.VotedressUser.UserDetail.Name + " " + t.VotedressUser.UserDetail.SurName, LikedId = t.VotedressUser.id, }), commentReplies = x.ProductCommentReply.OrderBy(k => k.CommentDate).Select(k => new { commentId = k.id, commentOwnerId = k.VotedressUser.id, commentOwnerFullName = k.VotedressUser.UserDetail.Name + " " + k.VotedressUser.UserDetail.SurName, commentOwnerProfilImage = k.VotedressUser.ProfileImage, comment = k.Comment, commentDate = k.CommentDate, commentLikes = k.ProductCommentReplyLike.Select(t => new { LikedFullName = t.VotedressUser.UserDetail.Name + " " + t.VotedressUser.UserDetail.SurName, LikedId = t.VotedressUser.id, }), }) }) } }; return(View(JsonModel)); }
public JsonResult UrunDetayiGetir(Guid UrunID) { ProductManager productManager = new ProductManager(); Product urun = productManager.UrunGetir(UrunID); int commentCount = urun.ProductComment.Count; for (int i = 0; i < urun.ProductComment.Count; i++) { commentCount = commentCount + urun.ProductComment[i].ProductCommentReply.Count(); } SocialShareManager socialShareManager = new SocialShareManager(); List <SocialShare> urunPaylasimi = socialShareManager.UrunPaylasimlariniGetir(UrunID); OylamaManager oylamaMnager = new OylamaManager(); int urunluOylamalarCount = oylamaMnager.UrunluOylamalariGetir(UrunID).Count(); int facebookShareCount = urunPaylasimi.Where(x => x.SocialName == "facebook").Count(); int instagramShareCount = urunPaylasimi.Where(x => x.SocialName == "instagram").Count(); int twitterShareCount = urunPaylasimi.Where(x => x.SocialName == "twitter").Count(); int votedressShareCount = urunPaylasimi.Where(x => x.SocialName == "votedress").Count(); var JsonModel = new { urun = new { id = urun.id, productName = urun.ProductName, productImage = urun.ProductImage, Collections = urun.ProductCollection.Select(k => new { id = k.Collection.id, collectionName = k.Collection.CollectionName, description = k.Collection.Description, createDate = k.Collection.CreateDate, }), price = urun.Price, shortDescription = urun.ShortDescription, longDescription = urun.LongDescription, uploadDate = urun.UploadDate, detail = urun.ProductSize.Select(k => new { productSize = k.Size, productColors = k.ProductColor.Select(y => new { id = y.id, stockCount = y.StockCount, color = y.ProductColorDetail.Select(u => new { colorName = u.Color.ColorName, colorCode = u.Color.ColorCode, }), productImageGallery = y.ProdutImageGallery.Select(u => new { id = u.id, imagePath = u.ImagePath }) }), }), urunSosyalGucu = new { facebookShareCount = facebookShareCount, instagramShareCount = instagramShareCount, twitterShareCount = twitterShareCount, votedressShareCount = votedressShareCount, urunluOylamalarCount = urunluOylamalarCount, commentCount = commentCount } } }; return(Json(JsonModel, JsonRequestBehavior.AllowGet)); }