コード例 #1
0
        public override async Task <UpdateProfessorResponse> UpdateProfessorById(UpdateProfessorRequest request, ServerCallContext context)
        {
            _logger.Log(LogLevel.Debug, "Request Received for CollegeGrpcService::UpdateProfessorById");

            var updatedProfessor = new UpdateProfessorResponse
            {
                Message = "success"
            };

            var professor = new Professor
            {
                ProfessorId = Guid.Parse(request.ProfessorId),
                Name        = request.Name,
                Teaches     = request.Teaches,
                Salary      = Convert.ToDecimal(request.Salary),
                IsPhd       = request.IsPhd
            };

            //professor = await _professorsSqlBll.UpdateProfessor(professor)
            //                                        .ConfigureAwait(false);

            professor = await _professorsCosmosBll.UpdateProfessor(professor)
                        .ConfigureAwait(false);

            updatedProfessor.Professor = GetProfessorObject(professor);

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

            return(updatedProfessor);
        }
コード例 #2
0
        public async Task <ActionResult> UpdateProfessor([FromBody] Professor professor)
        {
            var professorModified = await _professorsCosmosBll.UpdateProfessor(professor);

            if (professorModified == null)
            {
                return(StatusCode(404, $"Unable to find Professor with id {professor.ProfessorId}"));
            }

            return(NoContent());
        }