public void CanDelete() { using (var data = new DbTestData()) { var votesDAL = new VotesDAL(DbTestData.ConnectionString); var translationId = data.translation1.ID; dal.ReadById(translationId).Should().NotBeNull(); votesDAL.ReadAllByTranslationId(translationId).Should().NotBeEmpty(); dal.DeleteById(translationId); dal.ReadById(translationId).Should().BeNull(); votesDAL.ReadAllByTranslationId(translationId).Should().BeEmpty(); } }
// // GET: /Vote/ public ActionResult Index(int pollId = 1) { Poll poll = PollsDAL.GetPoll(pollId); if (poll == null) { return(Redirect("/Home/Index")); } ViewBag.Poll = poll; TimeSpan timeToNextVote = VotesDAL.TimeToNextVote(Request.ServerVariables["REMOTE_ADDR"], pollId); ViewBag.CanUserVote = timeToNextVote.TotalSeconds == 0; ViewBag.TimeToNextVote = string.Format("{0}:{1}:{2}", timeToNextVote.Hours, timeToNextVote.Minutes, timeToNextVote.Seconds); StringBuilder keywords = PossibleAnswersDAL.GetKeywords(pollId, poll); ViewBag.Keywords = keywords.ToString(); return(View()); }
public void CanDelete() { using (var data = new DbTestData()) { var projectsDAL = new ProjectsDAL(DbTestData.ConnectionString); var translationsDAL = new TranslationsDAL(DbTestData.ConnectionString); var votesDAL = new VotesDAL(DbTestData.ConnectionString); var user = data.user1; dal.ReadById(user.ID).Should().NotBeNull(); projectsDAL.ReadAllByUserId(user.ID).Should().NotBeEmpty(); translationsDAL.ReadAllByUserId(user.ID).Should().NotBeEmpty(); votesDAL.ReadAllByUserId(user.ID).Should().NotBeEmpty(); dal.DeleteById(user.ID); dal.ReadById(user.ID).Should().BeNull(); projectsDAL.ReadAllByUserId(user.ID).Should().BeEmpty(); translationsDAL.ReadAllByUserId(user.ID).Should().BeEmpty(); votesDAL.ReadAllByUserId(user.ID).Should().BeEmpty(); } }
public static void Init(TestContext context) { dal = new VotesDAL(DbTestData.ConnectionString); }
public VoteBL(VotesDAL votesDAL) { _votesDAL = votesDAL; }
public string GetTimeLeftToVote(int id) { TimeSpan timeToNextVote = VotesDAL.TimeToNextVote(Request.ServerVariables["REMOTE_ADDR"], id); return(string.Format("You can vote again after: {0:00}:{1:00}:{2:00}", timeToNextVote.Hours, timeToNextVote.Minutes, timeToNextVote.Seconds)); }
public ActionResult Vote(int answerId) { VotesDAL.AddVote(answerId, Request.ServerVariables["REMOTE_ADDR"]); return(Redirect("~/Home/Index?pageNumber=" + Session["pageNumber"])); }