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);
        }
        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 = _mapper.Map <Professor>(request);

            /*
             * // TODO: Technical Debt
             * 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 _professorsBll.UpdateProfessor(professor);

            updatedProfessor.Professor = GetProfessorObject(professor);

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

            return(updatedProfessor);
        }
        private async void buttonUpdate_Click(object sender, EventArgs e)
        {
            var updatedProfessor = new UpdateProfessorRequest
            {
                ProfessorId = textBoxProfessorId.Text,
                Name        = textBoxName.Text,
                Teaches     = textBoxTeaches.Text,
                Salary      = double.Parse(textBoxSalary.Text),
                IsPhd       = checkBoxIsPhd.Checked
            };

            var _ = await _client.UpdateProfessorByIdAsync(updatedProfessor);

            MessageBox.Show($"Professor Updated with Id: {updatedProfessor.ProfessorId}");
        }
Beispiel #4
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 = _mapper.Map <Professor>(request);

            professor = await _professorsBll.UpdateProfessor(professor);

            updatedProfessor.Professor = GetProfessorObject(professor);

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

            return(updatedProfessor);
        }