コード例 #1
0
        public override async Task <AllProfessorsResonse> GetAllProfessors(Empty request, ServerCallContext context)
        {
            AllProfessorsResonse allProfessorsResonse = new AllProfessorsResonse();

            var allProfessors = await _collegeDbContext.Professors.ToListAsync();

            allProfessorsResonse.Count = allProfessors.Count;

            foreach (var professor in allProfessors)
            {
                allProfessorsResonse.Professors.Add(GetProfessorObject(professor));
            }

            return(allProfessorsResonse);
        }
コード例 #2
0
        public override async Task <AllProfessorsResonse> GetAllProfessors(Empty request, ServerCallContext context)
        {
            AllProfessorsResonse allProfessorsResonse = new AllProfessorsResonse();

            _logger.Log(LogLevel.Debug, "Request Received for CollegeGrpcService::GetAllProfessors");

            var allProfessors = await _professorsBll.GetAllProfessors();

            allProfessorsResonse.Count = allProfessors.Count();

            foreach (var professor in allProfessors)
            {
                // TODO: Remove Technical Debt
                allProfessorsResonse.Professors.Add(_mapper.Map <GetProfessorResponse>(professor));
            }

            _logger.Log(LogLevel.Debug, "Returning the results from CollegeGrpcService::GetAllProfessors");

            return(allProfessorsResonse);
        }
コード例 #3
0
        public override async Task <AllProfessorsResonse> GetAllProfessors(Empty request, ServerCallContext context)
        {
            _logger.Log(LogLevel.Debug, "Request Received for CollegeGrpcService::GetAllProfessors");

            AllProfessorsResonse    allProfessorsResonse = new AllProfessorsResonse();
            IEnumerable <Professor> allProfessors;

            // Going to Data Store SQL Server
            allProfessors = _professorsBll.GetAllProfessors();

            allProfessorsResonse.Count = allProfessors.Count();

            foreach (var professor in allProfessors)
            {
                // TODO: Remove Technical Debt
                allProfessorsResonse.Professors.Add(GetProfessorObject(professor));
            }

            _logger.Log(LogLevel.Debug, "Returing the response from CollegeGrpcService::GetAllProfessors");
            return(await Task.FromResult(allProfessorsResonse));
        }
コード例 #4
0
        public override async Task <AllProfessorsResonse> GetAllProfessors(Empty request, ServerCallContext context)
        {
            Stopwatch            stopwatch            = new Stopwatch();
            AllProfessorsResonse allProfessorsResonse = new AllProfessorsResonse();

            stopwatch.Start();

            var allProfessors = _professorsBll.GetAllProfessors();

            stopwatch.Stop();
            _logger.Log(LogLevel.Warning, $"Time Taken to Retireve a Record: {stopwatch.ElapsedMilliseconds} ms");

            allProfessorsResonse.Count = allProfessors.Count();

            foreach (var professor in allProfessors)
            {
                // TODO: Remove Technical Debt
                allProfessorsResonse.Professors.Add(GetProfessorObject(professor));
            }

            return(await Task.FromResult(allProfessorsResonse));
        }
コード例 #5
0
        public override async Task <AllProfessorsResonse> GetAllProfessors(Empty request, ServerCallContext context)
        {
            Stopwatch            stopwatch            = new Stopwatch();
            AllProfessorsResonse allProfessorsResonse = new AllProfessorsResonse();

            stopwatch.Start();
            IEnumerable <Professor> allProfessors;
            // Try to get content from cache
            var professorsFromCache = _cache.GetString(Constants.RedisCacheStore.AllProfessorsKey);

            if (!string.IsNullOrEmpty(professorsFromCache))
            {
                //if they are there, deserialize them
                allProfessors = JsonConvert.DeserializeObject <IEnumerable <Professor> >(professorsFromCache);
            }
            else
            {
                // Going to Data Store SQL Server
                allProfessors = _professorsBll.GetAllProfessors();

                //and then, put them in cache
                _cache.SetString(Constants.RedisCacheStore.AllProfessorsKey,
                                 JsonConvert.SerializeObject(allProfessors),
                                 GetDistributedCacheEntryOptions());
            }
            stopwatch.Stop();
            _logger.Log(LogLevel.Warning, $"Time Taken to Retireve a Record: {stopwatch.ElapsedMilliseconds} ms");

            allProfessorsResonse.Count = allProfessors.Count();

            foreach (var professor in allProfessors)
            {
                // TODO: Remove Technical Debt
                allProfessorsResonse.Professors.Add(GetProfessorObject(professor));
            }

            return(await Task.FromResult(allProfessorsResonse));
        }