public ActionResult IsActive(int id) { var objENDebate = new enDebate() { ID = id }; var objBLDebate = new blDebate(objENDebate); try { objBLDebate.Read(); } catch { return(RedirectToAction("error", "misc")); } objENDebate.IsActive = false; objBLDebate = new blDebate(objENDebate); try { objBLDebate.Update(); } catch { return(RedirectToAction("error", "misc")); } return(RedirectToAction("create")); }
public ActionResult Update(int id, enDebate enDebate_) { var objENDebate = new enDebate() { ID = id }; var objBLDebate = new blDebate(objENDebate); try { objBLDebate.Read(); } catch { return(RedirectToAction("error", "misc")); } enDebate_.InsertedOn = objENDebate.InsertedOn; objBLDebate = new blDebate(enDebate_); try { objBLDebate.Update(); } catch { return(RedirectToAction("error", "misc")); } return(RedirectToAction("list")); }
private void ConstructObject(IDataReader dr_, enDebate enDebate_) { enDebate_.ID = Convert.ToInt32(dr_["ID"]); enDebate_.Topic = dr_["Topic"].ToString(); enDebate_.Description = dr_["Description"].ToString(); enDebate_.Date = Convert.ToDateTime(dr_["Date"]); enDebate_.Start = TimeSpan.Parse(dr_["Start"].ToString()); enDebate_.End = TimeSpan.Parse(dr_["End"].ToString()); enDebate_.User_ID = DBNull.Value == dr_["User_ID"] ? (int?)null : Convert.ToInt32(dr_["User_ID"]); enDebate_.LikesCount = DBNull.Value == dr_["LikesCount"] ? (int?)null : Convert.ToInt32(dr_["LikesCount"]); enDebate_.Category_ID = Convert.ToInt32(dr_["Category_ID"]); enDebate_.IsActive = Convert.ToBoolean(dr_["IsActive"]); enDebate_.InsertedOn = Convert.ToDateTime(dr_["InsertedOn"]); enDebate_.ModifiedOn = DBNull.Value == dr_["ModifiedOn"] ? (DateTime?)null : Convert.ToDateTime(dr_["ModifiedOn"]); }
public ActionResult Create(enDebate enDebate_) { var objBLDebate = new blDebate(enDebate_); enDebate_.IsActive = true; try { objBLDebate.Create(); } catch (Exception ex) { return(RedirectToAction("error", "misc")); } return(RedirectToAction("list")); }
public ActionResult List() { var objENDebate = new enDebate(); var objBLDebate = new blDebate(objENDebate); List <enDebate> listOfDebates = new List <enDebate>(); try { listOfDebates = objBLDebate.ReadAllAndAggregate(null, null, typeof(enCategory)); } catch { return(RedirectToAction("error", "misc")); } return(View(listOfDebates)); }
public ActionResult Update(int id) { var objENDebate = new enDebate() { ID = id }; var objBLDebate = new blDebate(objENDebate); try { objBLDebate.Read(); } catch { return(RedirectToAction("error", "misc")); } return(View("create", objENDebate)); }
public ActionResult Delete(int id) { var objENDebate = new enDebate() { ID = id }; var objBLDebate = new blDebate(objENDebate); try { objBLDebate.Delete(); } catch { return(RedirectToAction("error", "misc")); } return(RedirectToAction("list")); }
public List <enDebate> ReadAll(int?startRowIndex_ = null, int?endRowIndex_ = null) { var listOfDebates = new List <enDebate>(); using (IDataReader idr = base.Read(_enDebate.ID, _enDebate.Category_ID, startRowIndex_, endRowIndex_)) { while (idr.Read()) { var objENDebate = new enDebate(); ConstructObject(idr, objENDebate); listOfDebates.Add(objENDebate); _enDebate.IsGetSuccess = true; } if (idr.NextResult()) { idr.Read(); _enDebate.RecordsCount = Convert.ToInt32(idr["RecordsCount"]); } } return(listOfDebates); }
public dlDebate(enDebate enDebate_) : base("Debate") { this._enDebate = enDebate_; }
public ActionResult Index(int id) { #region Category var objENCategory = new enCategory() { ID = id }; var objBLCategory = new blCategory(objENCategory); try { objBLCategory.Read(); } catch (Exception ex) { throw; } ViewBag.Title = objENCategory.Name; #endregion var objENDebate = new enDebate() { Category_ID = id }; var objBLDebate = new blDebate(objENDebate); List <enDebate> listOfDebates = new List <enDebate>(); try { listOfDebates = objBLDebate.ReadAllAndAggregate(null, null, typeof(enUser)); } catch (Exception ex) { Log.Error("Hang-Out.UI.DebateController.Index() Error while Read() Debate Exception:- " + ex.ToString()); } foreach (var item in listOfDebates) { if (item.Date.Date < DateTime.Now.Date) { if (item.IsActive != false) { var objENLikeCounter = new enLikeCounter() { Debate_ID = item.ID }; var objBLLikeCounter = new blLikeCounter(objENLikeCounter); List <enLikeCounter> listOfLikesCounter = new List <enLikeCounter>(); try { listOfLikesCounter = objBLLikeCounter.ReadAll(); if (listOfLikesCounter.Count > 0) { var maxRepeated = listOfLikesCounter.GroupBy(s => s.User_ID).OrderByDescending(s => s.Count()).First().Key; int count = listOfLikesCounter.FindAll(x => x.User_ID == Convert.ToInt32(maxRepeated)).Count; if (Convert.ToInt32(count) > 0) { var objENReward = new enReward(); objENReward.Point = 50; objENReward.Type = (int)RewardType.WINNER; objENReward.User_ID = Convert.ToInt32(maxRepeated); var objBLReward = new blReward(objENReward); try { objBLReward.Create(); } catch (Exception ex) { Log.Error("Hang-Out.UI.DebateController.Index() Error while Create() Reward Exception:-" + ex.ToString()); return(RedirectToAction("error", "misc")); } item.IsActive = false; item.LikesCount = count; item.User_ID = maxRepeated; objBLDebate = new blDebate(item); try { objBLDebate.Update(); } catch (Exception ex) { Log.Error("Hang-Out.UI.DebateController.Index() Error while Update() Debate Exception:-" + ex.ToString()); return(RedirectToAction("error", "misc")); } } } } catch (Exception ex) { Log.Error("Hang-Out.UI.DebateController.Index() Error while Read() LikeCounter Exception:-" + ex.ToString()); return(RedirectToAction("error", "misc")); } } } else if (item.Date.Date == DateTime.Now.Date) { if (item.Start <= DateTime.Now.TimeOfDay && item.End >= DateTime.Now.TimeOfDay) { item.IsActive = true; } else if (item.Start <= DateTime.Now.TimeOfDay && item.End <= DateTime.Now.TimeOfDay) { if (item.IsActive != false) { item.IsActive = false; var objENLikeCounter = new enLikeCounter() { Debate_ID = item.ID }; var objBLLikeCounter = new blLikeCounter(objENLikeCounter); List <enLikeCounter> listOfLikesCounter = new List <enLikeCounter>(); try { listOfLikesCounter = objBLLikeCounter.ReadAll(); if (listOfLikesCounter.Count > 0) { var maxRepeated = listOfLikesCounter.GroupBy(s => s.User_ID).OrderByDescending(s => s.Count()).First().Key; int count = listOfLikesCounter.FindAll(x => x.User_ID == Convert.ToInt32(maxRepeated)).Count; if (Convert.ToInt32(count) > 0) { var objENReward = new enReward(); objENReward.Point = 50; objENReward.Type = (int)RewardType.WINNER; objENReward.User_ID = Convert.ToInt32(maxRepeated); var objBLReward = new blReward(objENReward); try { objBLReward.Create(); } catch (Exception ex) { Log.Error("Hang-Out.UI.DebateController.Index() Error while Create() Reward Exception:-" + ex.ToString()); return(RedirectToAction("error", "misc")); } item.LikesCount = count; item.User_ID = maxRepeated; objBLDebate = new blDebate(item); try { objBLDebate.Update(); } catch (Exception ex) { Log.Error("Hang-Out.UI.DebateController.Index() Error while Update() Debate Exception:-" + ex.ToString()); return(RedirectToAction("error", "misc")); } } } else { objBLDebate = new blDebate(item); try { objBLDebate.Update(); } catch (Exception ex) { Log.Error("Hangout.UI.DebateControl.Index() error while Update() Debate Exception:-" + ex.ToString()); } } } catch (Exception ex) { Log.Error("Hang-Out.UI.DebateController.Index() Error while Read() LikeCounter Exception:-" + ex.ToString()); return(RedirectToAction("error", "misc")); } } } else { item.IsActive = false; } } else { item.IsActive = false; } } return(View(listOfDebates)); }
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)); }
public blDebate(enDebate enDebate_) { this._enDebate = enDebate_; }