Ejemplo n.º 1
0
        public IActionResult Crea([FromBody] DocenteDTO docDTO)
        {
            if (docDTO == null)
            {
                return(BadRequest());
            }
            Docente doc = docDTO.ToDocente();

            work.Begin();
            work.DocentiRepo.Add(doc);
            work.Save();
            work.End();
            return(CreatedAtRoute(ROUTE_GET_COURSE, new { id = doc.IdDocente }, doc.ToDTO())); //risp al client
        }
Ejemplo n.º 2
0
        public IActionResult Update([FromBody] DocenteDTO docDTO)
        {
            if (docDTO == null)
            {
                return(BadRequest());
            }
            Docente doc = docDTO.ToDocente();

            try
            {
                work.Begin();
                work.DocentiRepo.Update(doc);
                work.Save();
                work.End();
            }
            catch (DataException)
            {
                return(NotFound());
            }
            return(NoContent());
        }