// GET: Index public ActionResult Index() { ArticlesManager articlesManager = new ArticlesManager(); var articles = articlesManager.GetData() .Select(item => new Article { ArticleName = item.ArticleName, ArticleText = item.ArticleText }) .ToList(); ViewBag.VoteType = "Vote"; if (Request.HttpMethod == "POST") { ViewBag.VoteType = "Result"; VotingManager votesManager = new VotingManager(); var genderValue = Request.Form["gender"]; if (genderValue == "Male") { votesManager.AddMaleVote(); } else if (genderValue == "Female") { votesManager.AddFemaleVote(); } Voting votes = votesManager.GetData(); ViewBag.Female = votes.Female; ViewBag.Male = votes.Male; return(View(articles)); } return(View(articles)); }
public ActionResult DeleteConfirmed(int id) { Voting voting = db.Votings.Find(id); db.Votings.Remove(voting); db.SaveChanges(); return(RedirectToAction("Index")); }
public void Given_NotStartedVoting_When_Vote_Then_Exception() { var voting = new Voting(); Action action = () => voting.Vote("C#"); Assert.ThrowsAny <InvalidOperationException>(action); }
public void ShouldNotBeAbleToSendStringValuesInIssuedBallots() { var voting = new Voting(); voting.SetIssuedBallots("abba"); voting.SendReport(); Assert.IsTrue(voting.IsErrorMessagePresent()); }
public void ShouldNotBeAbleToSendNegativeValuesInInvalidVotes() { var voting = new Voting(); voting.SetInvalidVotes("-10"); voting.SendReport(); Assert.IsTrue(voting.IsErrorMessagePresent()); }
public void Test_VotingId() { var expected = typeof(Guid); //setting what we expect the test to actually product var sut = new Voting(); var actual = sut.Id; Assert.True(expected == actual.GetType()); }
private void Dialog_ResultsCreatedEvent(Dictionary <string, string> result) { if (votings.VotingDict.ContainsKey(result["Name"])) { Voting selectedVoting = votings.VotingDict[result["Name"]]; selectedVoting.EndVoting(); } }
public void test_VotingId() { var expected = typeof(Guid); var sut = new Voting(); var actual = sut.Id; Assert.True(expected == actual.GetType()); }
public void Test_MovieVote() { var expected = 1; var sut = new Voting(); var actual = sut.Movie; Assert.NotNull(actual); }
public ActionResult DeleteVoting(Voting voting_) { var d_voting = db.Voting.Find(voting_.VotingID); db.Voting.Remove(d_voting); db.SaveChanges(); return(RedirectToAction("Votings")); }
public void Test_VotingPeople() { var expected = 0; //was 1?? do all movies get 1 vote to begin with? var sut = new Voting(); var actual = sut.People; Assert.True(typeof(List <Person>) == actual.GetType()); Assert.True(expected <= actual.Count); }
public ActionResult StopVoting(int id) { Voting voting = db.Votings.Find(id); voting.Active = false; db.Entry(voting).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Details/" + id)); }
private void Dialog_ResultsCreatedEvent(Dictionary <string, string> result) { if (votings.VotingDict.ContainsKey(result["Name"])) { Voting selectedVoting = votings.VotingDict[result["Name"]]; votingCommandHistory.Push(selectedVoting); selectedVoting.StartVoting(); } }
public static void Map(this Voting dbVoting, Voting voting) { dbVoting.Name = voting.Name; dbVoting.CategoryId = voting.CategoryId; dbVoting.VotersCount = voting.VotersCount; dbVoting.DateCreated = voting.DateCreated; dbVoting.DueDate = voting.DueDate; dbVoting.Description = voting.Description; }
public ActionResult ViteForIdea([FromBody] Voting voting) { if (_projectBll.VoteForIdea(voting)) { return(Ok()); } return(BadRequest()); }
public void Test_Voting_Id() { var expected = typeof(Guid); var h = new Voting(); var actual = h.Id; Assert.True(actual.GetType() == expected); }
public async Task Save(Voting voting, CancellationToken cancellationToken) { if (_context.Entry(voting).State == EntityState.Detached) { _context.Votings.Add(voting); } await _context.SaveChangesAsync(cancellationToken); }
public Voting AddVoting(Voting voting) { var auditLog = AuditLog.GetLog(Actions.Create, "Create new Voting"); Context.AuditLogs.Add(auditLog); Context.Votings.Add(voting); Context.SaveChanges(); return(voting); }
public async Task <ActionResult> DeleteConfirmed(int id) { Voting voting = await db.Voting.FindAsync(id); db.Voting.Remove(voting); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public void Test_Voting_HasVoters() { var expected = 0; var sut = new Voting(); var actual = sut.Persons; Assert.True(typeof(List <Person>) == actual.GetType()); Assert.True(actual.Count >= expected); }
public VotingViewModel(SessionItemViewModel sessionitem) { StartVotingCommand = new RelayCommand(StartVoting, CanStartVoting); CurrentModel = new Voting(); SessionItem = sessionitem; SessionItem.ObjectViewer.InitialVotingViewModel(this); }
public void ShouldNotBeAbleToEnterStringForVotes() { var voting = new Voting(); bool areVotesEntered = false; var candidate = voting.GetFirstCandidate(); areVotesEntered = voting.SetVotesForCandidate(candidate, "abba"); Assert.IsTrue(!areVotesEntered); }
public void AddVoting(Voting voting) { if (voting == null) { throw new ArgumentNullException("Voting"); } _votingRepository.AddVoting(voting); }
public void Test_VotingPeople() //testing to see if someone made a vote { var expected = 0; var sut = new Voting(); var actual = sut.People; Assert.True(typeof(List <Person>) == actual.GetType()); Assert.True(expected <= actual.Count); }
public void Test_VotingPersonList() { var expected = 1; var sut = new Voting(); var actual = sut.PeopleList; Assert.True(typeof(List <Person>) == actual.GetType()); Assert.True(expected <= actual.Count); }
/// <summary> /// Method Delete delete voting entity. /// </summary> /// <param name="entity">DalVoting entity.</param> public void Delete(DalVoting entity) { var vote = new Voting() { PhotoId = entity.PhotoId, UserId = entity.UserId }; context.Set <Voting>().Remove(vote); }
/// <summary> /// Method GetByPredicate return DalVoting by predicate. /// </summary> /// <param name="f">Predicate.</param> /// <returns>Return DalVoting by predicate f.</returns> public DalVoting GetByPredicate(Expression <Func <DalVoting, bool> > f) { Voting item = context.Set <Voting>().SingleOrDefault(f.ConvertExpressionVote()); return(new DalVoting { UserId = item.UserId, PhotoId = item.PhotoId, Rating = item.Rating }); }
public ActionResult Edit([Bind(Include = "VoteNumber,Members,Arrived,Pro,Contra,Not_Voted,DisserId,AuthorPass,DefenceId")] Voting voting) { if (ModelState.IsValid) //Если все верно введено { db.Entry(voting).State = EntityState.Modified; //состояние БД изменено db.SaveChanges(); //сохраняем изменения return(RedirectToAction("Index", new { id = voting.Defence.Number, author = voting.AuthorPass })); //и к жеталям } return(View(voting)); //Иначе все по-новой }
public Voting GetData() { Voting answer = new Voting(); using (BlogContext db = new BlogContext()) { answer = db.Voting.First(); } return(answer); }
public void Finish_Testing() { var voting = new Voting(); voting.Start("C#", "Java"); voting.Vote("C#"); var votingState = voting.Finish(); Assert.Equal("C#", votingState.Winner); }
public ActionResult Edit([Bind(Include = "ZemljeGlasaci,jedan,dva,tri,cetiri,pet,sest,sedam,osam,deset,dvanaest")] Voting voting) { if (ModelState.IsValid) { db.Entry(voting).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(voting)); }
private void WriteAttendInfo(XmlTextWriter xmlWriter, int scannerSerialNumber, Voting.Election election) { foreach (var blank in _electionManager.SourceData.Blanks) { if (election != null && _electionManager.SourceData.GetBlankIdByElectionNumber(election.ElectionId) != blank.Id) continue; var mask = new VoteKey { ScannerSerialNumber = scannerSerialNumber, BlankId = blank.Id }; xmlWriter.WriteStartElement("Bulletin"); xmlWriter.WriteAttributeString("id", blank.Id); xmlWriter.WriteAttributeString("n", XmlConvert.ToString(blank.Marker)); mask.BlankType = BlankType.Valid; xmlWriter.WriteAttributeString("Valid", XmlConvert.ToString(VotingResults.VotesCount(mask))); mask.BlankType = BlankType.NoMarks; xmlWriter.WriteAttributeString("NoMarks", XmlConvert.ToString(VotingResults.VotesCount(mask))); mask.BlankType = BlankType.TooManyMarks; xmlWriter.WriteAttributeString("TooManyMarks", XmlConvert.ToString(VotingResults.VotesCount(mask))); mask.BlankType = BlankType.BadMode; xmlWriter.WriteAttributeString("BadMode", XmlConvert.ToString(VotingResults.VotesCount(mask))); xmlWriter.WriteEndElement(); } }
private void WriteProtocolBody(XmlTextWriter xmlWriter, Voting.Election election) { xmlWriter.WriteStartElement("Protocol"); xmlWriter.WriteAttributeString("final", XmlConvert.ToString(!_isPreliminaryProtocol)); if (election != null) WriteElectionInfo(xmlWriter, election); else { foreach (var el in _electionManager.SourceData.Elections) WriteElectionInfo(xmlWriter, el); } xmlWriter.WriteEndElement(); }
private void WriteElectionInfo(XmlTextWriter xmlWriter, Voting.Election election) { xmlWriter.WriteStartElement("Election"); xmlWriter.WriteAttributeString("n", election.ExternalNumber); xmlWriter.WriteAttributeString("parentid", election.ParentComittee.ParentID); xmlWriter.WriteAttributeString("e-mail", election.ParentComittee.EMail); if (!_isPreliminaryProtocol) { foreach (var line in election.Protocol.Lines) { xmlWriter.WriteStartElement("Line"); xmlWriter.WriteAttributeString("n", XmlConvert.ToString(line.Num)); if (!string.IsNullOrEmpty(line.AdditionalNum)) xmlWriter.WriteAttributeString("a", line.AdditionalNum); xmlWriter.WriteString(XmlConvert.ToString(line.Value.GetValueOrDefault(0))); xmlWriter.WriteEndElement(); } } var showDisabledCandidates = !string.IsNullOrEmpty(election.Protocol.DisabledString); foreach (var candidate in election.Candidates) { if (candidate.Disabled && !showDisabledCandidates) continue; xmlWriter.WriteStartElement("Candidate"); xmlWriter.WriteAttributeString("n", candidate.Id); if (candidate.Disabled) xmlWriter.WriteAttributeString("disabled", XmlConvert.ToString(true)); var mask = new VoteKey { ElectionNum = election.ElectionId, CandidateId = candidate.Id }; var votesCount = VotingResults.VotesCount(mask); xmlWriter.WriteString(XmlConvert.ToString(votesCount)); xmlWriter.WriteEndElement(); } xmlWriter.WriteEndElement(); }
public void GenerateVotingResultProtocol(Voting.Election election) { _isPreliminaryProtocol = false; var timeStamp = DateTime.Now; var electionIndex = _electionManager.SourceData.GetElectionIndex(election); _votingResultProtocolFileName = GenerateVotingResultProtocolFileName(timeStamp, electionIndex + 1); _votingResultProtocolData = GenerateVotingResultProtocolData(timeStamp, election); SaveVotingResultProtocolToLocalDir(); }
private string GenerateVotingResultProtocolData(DateTime timeStamp, Voting.Election election) { using (var stringWriter = new StringWriter()) { using (var xmlWriter = new XmlTextWriter(stringWriter)) { xmlWriter.WriteStartElement("Xib", VOTINGRESULTPROTOCOL_XMLNS); xmlWriter.WriteAttributeString("uik", _electionManager.SourceData.Uik.ToString()); xmlWriter.WriteAttributeString("isGasVrn", XmlConvert.ToString(_electionManager.SourceData.IsGasVrn)); xmlWriter.WriteAttributeString( "ts", XmlConvert.ToString(timeStamp, XmlDateTimeSerializationMode.Local)); xmlWriter.WriteAttributeString( "version", XmlConvert.ToString(GetNextVotingResultProtocolVersion())); WriteScannersInfo(xmlWriter, election); WriteProtocolBody(xmlWriter, election); xmlWriter.WriteElementString("Check", String.Empty); xmlWriter.WriteEndElement(); } stringWriter.Flush(); return stringWriter.ToString(); } }
private void WriteScannersInfo(XmlTextWriter xmlWriter, Voting.Election election) { var scannerArr = _scannersInfo.GetScannerInfos(); foreach (var scanner in scannerArr) { var intScannerSerialNumber = Convert.ToInt32(scanner.SerialNumber); xmlWriter.WriteStartElement("Scanner"); xmlWriter.WriteAttributeString("n", scanner.SerialNumber); var mask = new VoteKey { ScannerSerialNumber = intScannerSerialNumber, BlankType = BlankType.Bad, }; var nufCount = VotingResults.VotesCount(mask); xmlWriter.WriteAttributeString("nuf", XmlConvert.ToString(nufCount)); if (election != null) WriteAttendInfo(xmlWriter, intScannerSerialNumber, election); else { foreach (var el in _electionManager.SourceData.Elections) WriteAttendInfo(xmlWriter, intScannerSerialNumber, el); } xmlWriter.WriteEndElement(); } }