public void SubmitVote(int userID, int submissionID, int voteType) { SubmissionDAO subDAO = new SubmissionDAO(); String submitVote = "INSERT INTO tbl_User_Rating_Submission_xref " + "(UserID, SubmissionID, VoteType) " + "VALUES (" + userID + ", " + submissionID + ", " + voteType + ")" + "SELECT scope_identity()"; try { DbCommand command = Database.GetSqlStringCommand(submitVote); Database.ExecuteScalar(command); subDAO.AdjustRating(submissionID, voteType); } catch (Exception e) { LogError("Something exploded while trying to submit a vote!", e); throw new Exception("Something exploded while trying to submit a vote!", e); } }
public void CreateNewSubmission(string title, string link, string username) { SubmissionDAO dao = new SubmissionDAO(); UserDAO userDAO = new UserDAO(); SubmissionVO newSub = new SubmissionVO(); if (title == null) { throw new Exception("You need to enter a title"); } if (link == null) { throw new Exception("You need to enter a link"); } newSub.Title = title; newSub.Link = link; newSub.Rating = 0; newSub.PostTime = DateTime.Now; newSub.UserID = userDAO.GetUser(username).UserID; dao.InsertSubmission(newSub); }
public List<SubmissionVO> GetListOfSubmissionsByUser(int size, int userID) { List<SubmissionVO> subList; SubmissionDAO dao = new SubmissionDAO(); subList = dao.GetAllUsersSubmissions(userID); subList.Sort((x, y) => DateTime.Compare(y.PostTime, x.PostTime)); TruncateList(subList, size); return subList; }
public SubmissionVO GetSubmission(int subID) { SubmissionDAO dao = new SubmissionDAO(); return dao.GetSubmission(subID); }
public List<SubmissionVO> GetListOfSubmissionsTop(int size) { List<SubmissionVO> subList; SubmissionDAO dao = new SubmissionDAO(); subList = dao.GetAllSubmissions(); subList.Sort((x, y) => y.Rating.CompareTo(x.Rating)); TruncateList(subList, size); return subList; }
public List<SubmissionVO> GetListOfSubmissionsPopular(int size) { List<SubmissionVO> subList; SubmissionDAO dao = new SubmissionDAO(); subList = dao.GetAllSubmissions(); subList.Sort((x, y) => y.Rating.CompareTo(x.Rating)); List<SubmissionVO> newList = new List<SubmissionVO>(); //Can't remove things from a list in a foreach foreach (SubmissionVO vo in subList) { if (!(vo.PostTime.Date < DateTime.Now.AddDays(-1d))) { newList.Add(vo); } } subList = newList; TruncateList(subList, size); return subList; }
public List<SubmissionVO> GetListOfSubmissionsNew(int size) { List<SubmissionVO> subList = new List<SubmissionVO>(); SubmissionDAO dao = new SubmissionDAO(); subList = dao.GetAllSubmissions(); subList.Sort((x, y) => DateTime.Compare(y.PostTime, x.PostTime)); TruncateList(subList, size); return subList; }