Esempio n. 1
0
        public ActionResult GetProgramById(int id)
        {
            _logger.LogInformation("Getting a programs");
            var program       = _programService.GetById(id);
            var programModels = ProgramMapper.SerializeProgram(program);

            return(Ok(programModels));
        }
Esempio n. 2
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));
        }
Esempio n. 3
0
        public ActionResult UpdateProgram([FromBody] ProgramModel program)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            program.LastUpdate = DateTime.UtcNow;
            var programData = ProgramMapper.SerializeProgram(program);
            var newProgram  = _programService.UpdateProgram(programData);

            return(Ok(newProgram));
        }