Ejemplo n.º 1
0
        public static CorsoDocenteDTO ToDTO(this CorsoDocente corsoDocente)
        {
            if (corsoDocente == null)
            {
                return(null);
            }

            return(new CorsoDocenteDTO
            {
                IdEdizioneCorso = corsoDocente.IdEdizioneCorso,
                IdDocente = corsoDocente.IdDocente,
                ValutazioneMedia = corsoDocente.ValutazioneMedia
            });
        }
Ejemplo n.º 2
0
        public IActionResult Post([FromBody] CorsoDocenteDTO value)
        {
            if (value == null)
            {
                return(BadRequest());
            }
            CorsoDocente Docente = value.ToCorsoDocente();

            work.Begin();
            work.CorsiDocentiRepo.Add(Docente);
            work.Save();
            work.End();

            return(CreatedAtRoute("ROUTE_GET_COURSE", new { id = Docente.IdEdizioneCorso }, Docente.ToDTO()));

            //return CreatedAtAction("GetCorsoDocente", new { id = corsoDocente.IdDocente }, corsoDocente);
        }
Ejemplo n.º 3
0
        public IActionResult Get(int id) //GetCorsoDocente anche
        {
            CorsoDocente corso = context.CorsiDocenti.Find(id);

            if (corso == null)
            {
                return(NotFound());
            }
            return(Ok(corso));
            //if (id < 1)
            //{
            //    return BadRequest();
            //}

            //var corsoDocente = work.CorsiDocentiRepo.FindAll().Select(cd => cd.ToDTO()); // 26' PER QUESTA RIGA

            //if (corsoDocente == null)
            //{
            //    return NotFound();
            //}

            //return Ok(corsoDocente);
        }
Ejemplo n.º 4
0
 public void Update(CorsoDocente corsoDocente)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 5
0
        //IEnumerable<CorsoDocente> ICorsiDocentiRepository.FindByName(string s)
        //{
        //    throw new NotImplementedException();
        //}

        void ICorsiDocentiRepository.Update(CorsoDocente corsoDocente)
        {
            throw new NotImplementedException();
        }
Ejemplo n.º 6
0
 public void Add(CorsoDocente corsoDocente)
 {
     context.CorsiDocenti.Add(corsoDocente);
     context.SaveChanges();
 }