コード例 #1
0
        // 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));
        }
コード例 #2
0
ファイル: VotingsController.cs プロジェクト: Ndabe/SMS
        public ActionResult DeleteConfirmed(int id)
        {
            Voting voting = db.Votings.Find(id);

            db.Votings.Remove(voting);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #3
0
        public void Given_NotStartedVoting_When_Vote_Then_Exception()
        {
            var voting = new Voting();

            Action action = () => voting.Vote("C#");

            Assert.ThrowsAny <InvalidOperationException>(action);
        }
コード例 #4
0
        public void ShouldNotBeAbleToSendStringValuesInIssuedBallots()
        {
            var voting = new Voting();

            voting.SetIssuedBallots("abba");
            voting.SendReport();
            Assert.IsTrue(voting.IsErrorMessagePresent());
        }
コード例 #5
0
        public void ShouldNotBeAbleToSendNegativeValuesInInvalidVotes()
        {
            var voting = new Voting();

            voting.SetInvalidVotes("-10");
            voting.SendReport();
            Assert.IsTrue(voting.IsErrorMessagePresent());
        }
コード例 #6
0
        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());
        }
コード例 #7
0
 private void Dialog_ResultsCreatedEvent(Dictionary <string, string> result)
 {
     if (votings.VotingDict.ContainsKey(result["Name"]))
     {
         Voting selectedVoting = votings.VotingDict[result["Name"]];
         selectedVoting.EndVoting();
     }
 }
コード例 #8
0
        public void test_VotingId()
        {
            var expected = typeof(Guid);
            var sut      = new Voting();
            var actual   = sut.Id;

            Assert.True(expected == actual.GetType());
        }
コード例 #9
0
ファイル: VotingTests.cs プロジェクト: ccarrjoh/Hello-VS1
        public void Test_MovieVote()
        {
            var expected = 1;
            var sut      = new Voting();
            var actual   = sut.Movie;

            Assert.NotNull(actual);
        }
コード例 #10
0
        public ActionResult DeleteVoting(Voting voting_)
        {
            var d_voting = db.Voting.Find(voting_.VotingID);

            db.Voting.Remove(d_voting);
            db.SaveChanges();
            return(RedirectToAction("Votings"));
        }
コード例 #11
0
ファイル: VotingTests.cs プロジェクト: bezp/HelloCS
        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);
        }
コード例 #12
0
        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));
        }
コード例 #13
0
 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();
     }
 }
コード例 #14
0
 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;
 }
コード例 #15
0
        public ActionResult ViteForIdea([FromBody] Voting voting)
        {
            if (_projectBll.VoteForIdea(voting))
            {
                return(Ok());
            }

            return(BadRequest());
        }
コード例 #16
0
ファイル: VotingTests.cs プロジェクト: ccarrjoh/Hello-VS1
        public void Test_Voting_Id()
        {
            var expected = typeof(Guid);
            var h        = new Voting();

            var actual = h.Id;

            Assert.True(actual.GetType() == expected);
        }
コード例 #17
0
        public async Task Save(Voting voting, CancellationToken cancellationToken)
        {
            if (_context.Entry(voting).State == EntityState.Detached)
            {
                _context.Votings.Add(voting);
            }

            await _context.SaveChangesAsync(cancellationToken);
        }
コード例 #18
0
        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);
        }
コード例 #19
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            Voting voting = await db.Voting.FindAsync(id);

            db.Voting.Remove(voting);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
コード例 #20
0
        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);
        }
コード例 #21
0
        public VotingViewModel(SessionItemViewModel sessionitem)
        {
            StartVotingCommand = new RelayCommand(StartVoting, CanStartVoting);
            CurrentModel       = new Voting();

            SessionItem = sessionitem;

            SessionItem.ObjectViewer.InitialVotingViewModel(this);
        }
コード例 #22
0
        public void ShouldNotBeAbleToEnterStringForVotes()
        {
            var  voting          = new Voting();
            bool areVotesEntered = false;
            var  candidate       = voting.GetFirstCandidate();

            areVotesEntered = voting.SetVotesForCandidate(candidate, "abba");
            Assert.IsTrue(!areVotesEntered);
        }
コード例 #23
0
        public void AddVoting(Voting voting)
        {
            if (voting == null)
            {
                throw new ArgumentNullException("Voting");
            }

            _votingRepository.AddVoting(voting);
        }
コード例 #24
0
        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);
        }
コード例 #25
0
        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
            });
        }
コード例 #28
0
 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));                                                                                  //Иначе все по-новой
 }
コード例 #29
0
        public Voting GetData()
        {
            Voting answer = new Voting();

            using (BlogContext db = new BlogContext())
            {
                answer = db.Voting.First();
            }
            return(answer);
        }
コード例 #30
0
        public void Finish_Testing()
        {
            var voting = new Voting();

            voting.Start("C#", "Java");
            voting.Vote("C#");
            var votingState = voting.Finish();

            Assert.Equal("C#", votingState.Winner);
        }
コード例 #31
0
 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));
 }
コード例 #32
0
ファイル: VotingResultManager.cs プロジェクト: nico-izo/KOIB
 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();
     }
 }
コード例 #33
0
ファイル: VotingResultManager.cs プロジェクト: nico-izo/KOIB
 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();
 }
コード例 #34
0
ファイル: VotingResultManager.cs プロジェクト: nico-izo/KOIB
 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();
 }
コード例 #35
0
ファイル: VotingResultManager.cs プロジェクト: nico-izo/KOIB
 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();
 }
コード例 #36
0
ファイル: VotingResultManager.cs プロジェクト: nico-izo/KOIB
 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();
     }
 }
コード例 #37
0
ファイル: VotingResultManager.cs プロジェクト: nico-izo/KOIB
 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();
     }
 }