public async Task <bool> EliminaCorso(Corso c) { bool result = false; Modulo m = await _db.Moduli.FirstOrDefaultAsync(x => x.IdCorso == c.Id); StudenteIscritto s = await _db.StudentiIscritti.FirstOrDefaultAsync(x => x.IdCorso == c.Id); if (m == null && s == null) { _db.Corsi.Remove(c); await _db.SaveChangesAsync(); result = true; } return(result); }
public async Task <bool> SalvaCorso(Corso c) { bool result = false; Citta citta = await _db.Citta.FindAsync(c.IdCitta); PersonaFitstic p = await _db.PersonaleFitstic.FindAsync(c.IdOrganizzatore); if (citta != null && p != null) { _db.Corsi.Add(c); await _db.SaveChangesAsync(); result = true; } return(result); }
public async Task <bool> SalvaIscrizione(StudenteIscritto s) { bool result = false; Corso c = await _db.Corsi.FindAsync(s.IdCorso); Studente st = await _db.Studenti.FindAsync(s.IdStudente); if (c != null && st != null) { _db.StudentiIscritti.Add(s); await _db.SaveChangesAsync(); result = true; } return(result); }
public async Task <bool> SalvaModulo(Modulo modulo) { bool result = false; PersonaFitstic d = await _db.PersonaleFitstic.FindAsync(modulo.IdDocente); PersonaFitstic t = await _db.PersonaleFitstic.FindAsync(modulo.IdTutor); Corso c = await _db.Corsi.FindAsync(modulo.IdCorso); if (d != null && t != null && c != null) { _db.Moduli.Add(modulo); await _db.SaveChangesAsync(); result = true; } return(result); }
public async Task <bool> EliminaPersona(PersonaFitstic p) { bool result = false; Modulo m1 = await _db.Moduli.FirstOrDefaultAsync(x => x.IdDocente == p.Id); Modulo m2 = await _db.Moduli.FirstOrDefaultAsync(x => x.IdTutor == p.Id); Corso c = await _db.Corsi.FirstOrDefaultAsync(x => x.IdOrganizzatore == p.Id); if (m1 == null && m2 == null && c == null) { _db.PersonaleFitstic.Remove(p); await _db.SaveChangesAsync(); result = true; } return(result); }
public async Task <List <Modulo> > GetModuliDelCorso(Corso corso) { return(await _db.Moduli.Where(x => x.IdCorso == corso.Id).ToListAsync()); }
public async Task <List <IServizioStudenti.StudentiDelCorso> > GetStudentiDelCorso(Corso c) { List <IServizioStudenti.StudentiDelCorso> Studenti = new List <IServizioStudenti.StudentiDelCorso>(); var studenti = await(from studente in _db.Studenti join studenteIscritto in _db.StudentiIscritti on studente.Id equals studenteIscritto.IdStudente where studenteIscritto.IdCorso == c.Id select new IServizioStudenti.StudentiDelCorso { Id = studenteIscritto.Id, Nome = studente.Nome, Cognome = studente.Cognome, DataIscrizione = studenteIscritto.DataIscrizione, NonAmmesso = studenteIscritto.NonAmmesso, Ritirato = studenteIscritto.Ritirato, VotoFinale = studenteIscritto.VotoFinale, IdCorso = studenteIscritto.IdCorso }).ToListAsync(); foreach (var s in studenti) { Studenti.Add(s); } return(Studenti); }