public async Task <ActionResult> Put(int id, [FromBody] ProgramUpdateDto program)
        {
            _logger.LogInformation(ConstantVarriables.ProgramApiPutProgramEnterMessage);
            ObjectResult response;

            if (id != program.ProgramId)
            {
                response = BadRequest(ConstantVarriables.NoValidData);
            }
            else
            {
                try
                {
                    var programEntity = _mapper.Map <ProgramMaster>(program);
                    await _programService.UpdateProgram(id, programEntity);

                    response = Ok(ConstantVarriables.DataUpdated);
                }
                catch (Exception ex)
                {
                    _logger.LogError(ex, ex.Message);
                    response = BadRequest(ConstantVarriables.GenericExeptionMessage);
                }
            }
            _logger.LogInformation(ConstantVarriables.ProgramApiPutProgramExitMessage);
            return(response);
        }
Exemplo n.º 2
0
        public async Task Program_Put_Test()
        {
            ProgramUpdateDto program = new ProgramUpdateDto()
            {
                ProgramId   = 7,
                ProgramName = "Test Program Update",
                ClassId     = 1
            };
            var results = await _programApiController.Put(program.ProgramId, program);

            var objectResult = results as ObjectResult;

            Assert.NotNull(results);
            Assert.NotNull(objectResult);
            Assert.AreEqual(200, objectResult.StatusCode);
        }