コード例 #1
0
        public ActionResult AddProgram([FromBody] ProgramModel program)
        {
            _logger.LogInformation("Adding a new Program");

            program.LastUpdate = DateTime.UtcNow;
            var programData = ProgramMapper.SerializeProgram(program);
            var newProgram  = _programService.CreateProgram(programData);

            return(Ok(newProgram));
        }
コード例 #2
0
        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);
        }