public async Task Program_Post_Test() { ProgramCreationDto program = new ProgramCreationDto() { ProgramName = "Test Program", ClassId = 1 }; var results = await _programApiController.Post(program); var objectResult = results as ObjectResult; Assert.NotNull(results); Assert.NotNull(objectResult); Assert.AreEqual(200, objectResult.StatusCode); }
public async Task <ActionResult> Post([FromBody] ProgramCreationDto program) { _logger.LogInformation(ConstantVarriables.ProgramApiPostProgramEnterMessage); ObjectResult response; try { var programEntity = _mapper.Map <ProgramMaster>(program); await _programService.CreateProgram(programEntity); response = Ok(ConstantVarriables.DataSaved); } catch (Exception ex) { _logger.LogError(ex, ex.Message); response = BadRequest(ConstantVarriables.GenericExeptionMessage); } _logger.LogInformation(ConstantVarriables.ProgramApiPostProgramExitMessage); return(response); }