Beispiel #1
0
        public async Task <Cours> CreateCours(Cours cours)
        {
            var lists = this._context.Cours.ToList();

            cours.Id = 1;

            foreach (Cours list in lists)
            {
                if (list.Id == cours.Id)
                {
                    cours.Id += 1;
                }
            }

            await _context.Cours.AddAsync(cours);

            await _context.SaveChangesAsync();

            return(cours);
        }
Beispiel #2
0
        public async Task <Classe> CreateClasse(Classe classe)
        {
            var lists = this._context.Classes.ToList();

            classe.Id = 1;

            foreach (Classe list in lists)
            {
                if (list.Id == classe.Id)
                {
                    classe.Id += 1;
                }
            }

            await _context.Classes.AddAsync(classe);

            await _context.SaveChangesAsync();

            return(classe);
        }
Beispiel #3
0
        public async Task <IActionResult> addCours(Cours cours)
        {
            var indisp = _context.Indisponibilites.Where(a => a.ProfesseurId == cours.ProfesseurId).ToList();
            var lists  = this._context.Cours.ToList();

            cours.Id = 1;

            foreach (Cours list in lists)
            {
                if (list.Id == cours.Id)
                {
                    cours.Id += 1;
                }
            }

            foreach (var item in indisp)
            {
                if (cours.Start >= item.Start && cours.Start <= item.End)
                {
                    return(BadRequest("Prof indisponible"));
                }
                if (cours.End >= item.Start && cours.End <= item.End)
                {
                    return(BadRequest("Prof indisponible"));
                }
            }

            if (cours.Start > cours.End)
            {
                return(BadRequest("Date de fin inférieure à la date de début"));
            }

            await _context.Cours.AddAsync(cours);

            await _context.SaveChangesAsync();

            return(Ok(cours));
        }
Beispiel #4
0
        public async Task <User> Register(User user, string password)
        {
            byte[] passwordHash, passwordSalt;
            CreatePasswordHash(password, out passwordHash, out passwordSalt);

            // user.PasswordHash = passwordHash;
            // user.PasswordSalt = passwordSalt;

            await _context.Users.AddAsync(user);

            await _context.SaveChangesAsync();

            return(user);
        }
Beispiel #5
0
        public async Task <IActionResult> addIndisponibilite(Indisponibilite indisp)
        {
            var lists = this._context.Indisponibilites.ToList();

            indisp.Id = 1;

            foreach (Indisponibilite list in lists)
            {
                if (list.Id == indisp.Id)
                {
                    indisp.Id += 1;
                }
            }
            if (indisp.Start > indisp.End)
            {
                return(BadRequest("Date de fin inférieure à la date de début"));
            }

            await _context.Indisponibilites.AddAsync(indisp);

            await _context.SaveChangesAsync();

            return(Ok(indisp));
        }
Beispiel #6
0
        public async Task <IActionResult> Put(int id, [FromBody] Prof prof)
        {
            var dbProf = _context.Profs.FirstOrDefault(x => x.Id == id);

            dbProf.Nom       = prof.Nom;
            dbProf.Prenom    = prof.Prenom;
            dbProf.Adresse   = prof.Adresse;
            dbProf.Mail      = prof.Mail;
            dbProf.Telephone = prof.Telephone;
            dbProf.Nom       = prof.Nom;
            dbProf.Note      = prof.Note;

            _context.Profs.Update(dbProf);
            await _context.SaveChangesAsync();

            return(Ok());
        }
        public async Task <Niveau> CreateNiveau(Niveau niveau)
        {
            var lists = this._context.Niveaux.ToList();

            niveau.Id = 1;

            foreach (Niveau list in lists)
            {
                if (list.Id == niveau.Id)
                {
                    niveau.Id += 1;
                }
            }

            await _context.Niveaux.AddAsync(niveau);

            await _context.SaveChangesAsync();

            return(niveau);
        }
        public async Task <Indisponibilite> CreateIndisponibilite(Indisponibilite indisponibilite)
        {
            var lists = this._context.Indisponibilites.ToList();

            indisponibilite.Id = 1;

            foreach (Indisponibilite list in lists)
            {
                if (list.Id == indisponibilite.Id)
                {
                    indisponibilite.Id += 1;
                }
            }

            await _context.Indisponibilites.AddAsync(indisponibilite);

            await _context.SaveChangesAsync();

            return(indisponibilite);
        }
Beispiel #9
0
        public async Task <Prof> CreateProf(Prof prof)
        {
            var lists = this._context.Profs.ToList();

            prof.Id = 1;

            foreach (Prof list in lists)
            {
                if (list.Id == prof.Id)
                {
                    prof.Id += 1;
                }
            }

            await _context.Profs.AddAsync(prof);

            await _context.SaveChangesAsync();

            return(prof);
        }
        public async Task <Matiere> CreateMatiere(Matiere matiere)
        {
            var lists = this._context.Matieres.ToList();

            matiere.Id = 1;

            foreach (Matiere list in lists)
            {
                if (list.Id == matiere.Id)
                {
                    matiere.Id += 1;
                }
            }

            await _context.Matieres.AddAsync(matiere);

            await _context.SaveChangesAsync();

            return(matiere);
        }
Beispiel #11
0
        public async Task <Eleve> CreateEleve(Eleve eleve)
        {
            var lists = this._context.Eleves.ToList();

            eleve.Id = 1;

            foreach (Eleve list in lists)
            {
                if (list.Id == eleve.Id)
                {
                    eleve.Id += 1;
                }
            }

            await _context.Eleves.AddAsync(eleve);

            await _context.SaveChangesAsync();

            return(eleve);
        }
Beispiel #12
0
        public async Task <Annee> CreateAnnee(Annee annee)
        {
            var lists = this._context.Annees.ToList();

            annee.Id = 1;

            foreach (Annee list in lists)
            {
                if (list.Id == annee.Id)
                {
                    annee.Id += 1;
                }
            }

            await _context.Annees.AddAsync(annee);

            await _context.SaveChangesAsync();

            return(annee);
        }
Beispiel #13
0
 public async Task <bool> SaveAll()
 {
     return(await _context.SaveChangesAsync() > 0);
 }