public ActionResult getParticepent(int debateID) { var objENComment = new enComment() { Debate_ID = debateID }; var objBLComment = new blComment(objENComment); List <enComment> listOfComments = new List <enComment>(); try { listOfComments = objBLComment.ReadAllAndAggregate(null, null, typeof(enDebate), typeof(enUser)); } catch { return(RedirectToAction("error", "misc")); } listOfComments = listOfComments.DistinctBy(x => x.User_ID).ToList(); foreach (var item in listOfComments) { var objENLikeCounter = new enLikeCounter() { User_ID = item.User_ID, Debate_ID = item.Debate_ID }; var objBLLikeCounter = new blLikeCounter(objENLikeCounter); List <enLikeCounter> listOfLikesCounters = new List <enLikeCounter>(); try { listOfLikesCounters = objBLLikeCounter.ReadAll(); item.LikesCount = listOfLikesCounters.Count(); } catch { return(RedirectToAction("error", "misc")); } } return(Json(listOfComments, JsonRequestBehavior.AllowGet)); }
public ActionResult DebateRoom(int debateID) { var objENDebate = new enDebate() { ID = debateID }; var objBLDebate = new blDebate(objENDebate); try { objBLDebate.Read(); } catch (Exception ex) { Log.Error("Hangout.UI.DebateController.DebateRoom() Error while Read() Debate Exception:-" + ex.ToString()); } ViewBag.DebateTopic = objENDebate.Topic; ViewBag.DebateDescription = objENDebate.Description; var objENComment = new enComment() { Debate_ID = debateID }; var objBLComment = new blComment(objENComment); List <enComment> listOfComments = new List <enComment>(); try { listOfComments = objBLComment.ReadAllAndAggregate(null, null, typeof(enUser), typeof(enLikeCounter)); } catch (Exception ex) { Log.Error("Hangout.UI.DebateController.DebateRoom() Error while Read() Comment Exception:-" + ex.ToString()); } if (listOfComments.Count > 0) { List <enComment> listOfDistinctID = listOfComments.DistinctBy(x => x.User_ID).ToList(); ViewBag.DistinctID = listOfDistinctID; } var objCommentModel = new CommentModel(); objCommentModel.listOfComments = listOfComments.OrderBy(x => x.ID).ToList(); ViewBag.ForListOfComments = listOfComments.FindAll(x => x.Type == (int)CommentType.FOR).OrderBy(x => x.InsertedOn); ViewBag.AgainstListOfComments = listOfComments.FindAll(x => x.Type == (int)CommentType.AGAINST).OrderBy(x => x.InsertedOn); objCommentModel.Comments_ = objENComment; ViewBag.UserID = CookieDetail.UserID; var objENDebateAdvertisement = new enDebateAdvertisement() { GetByDate = 1 }; var objBLDebateAdvertisement = new blDebateAdvertisement(objENDebateAdvertisement); List <enDebateAdvertisement> listOfDebaetAdvertisements = new List <enDebateAdvertisement>(); try { listOfDebaetAdvertisements = objBLDebateAdvertisement.ReadAllAndAggregate(typeof(enDebateAdvertisementImage)); } catch (Exception ex) { } var count = listOfDebaetAdvertisements.FirstOrDefault().ListOfDebateAdvertisementImage_.Count; if (count > 0) { var half = count / 2; var secondlistIndex = count - half; ViewBag.LeftDebateAdvertisementImage = listOfDebaetAdvertisements.FirstOrDefault().ListOfDebateAdvertisementImage_.GetRange(0, half); ViewBag.RightDebateAdvertisementImage = listOfDebaetAdvertisements.FirstOrDefault().ListOfDebateAdvertisementImage_.GetRange(half, secondlistIndex); } return(View(objCommentModel)); }