コード例 #1
0
        protected StatResource.StatPersistence AddStat(StatResource stat, StatResource.StatPersistence total)
        {
            if (stat == null)
            {
                return(null);
            }

            Debug.Assert(stat != null, "Please dont leave the '{}' stat empty.".Replace("{}", stat.name));
            var repr = new StatResource.StatPersistence(stat, total);

            _dictionary.Add(repr.TypeId, repr);

            return(repr);
        }
        public IActionResult GetStats()
        {
            try
            {
                var activeSemester = Repository.GetCurrentSemester();

                var semesterStudents = Repository.GetStudentsCount(activeSemester.Id);

                var currentProposals = _proposalRepository.GetProposalCount(activeSemester.Id);

                var stats = new StatResource
                {
                    AcceptedProposal = currentProposals.Count(x => x.Status == ProposalStstus.Accepted),
                    TotalProposal    = currentProposals.Count,
                    CurrentStudents  = semesterStudents
                };

                return(Ok(stats));
            }
            catch (Exception e)
            {
                return(BadRequest());
            }
        }