Ejemplo n.º 1
0
        public override Task <AddProfessorResponse> AddProfessor(AddProfessorRequest request, ServerCallContext context)
        {
            _logger.Log(LogLevel.Debug, "Request Received for CollegeGrpcService::AddProfessor");

            var newProfessor = new AddProfessorResponse
            {
                Message = "success"
            };

            // TODO: Remove Technical Debt
            var professor = new Professor
            {
                Name    = request.Name,
                Doj     = request.Doj.ToDateTime(),
                Teaches = request.Teaches,
                Salary  = Convert.ToDecimal(request.Salary),
                IsPhd   = request.IsPhd
            };

            var results = _professorsBll.AddProfessor(professor);

            newProfessor.ProfessorId = results.ProfessorId.ToString();

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

            return(Task.FromResult(newProfessor));
        }
        public async Task <ActionResult <AddProfessorResponse> > AddProfessor([FromBody] AddProfessorRequest professor)
        {
            _logger.Log(LogLevel.Debug, "Request Received for ProfessorsController::AddProfessor");

            var results = await _collegeServiceClient.AddProfessorAsync(professor);

            _logger.Log(LogLevel.Debug, "Sending Response from ProfessorsController::AddProfessor");

            return(Created(string.Empty, results));
        }