public async Task <IActionResult> PutMedicalServices(long id, MedicalService medicalServices)
        {
            if (id != medicalServices.Id)
            {
                return(BadRequest());
            }

            _context.Entry(medicalServices).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!MedicalServicesExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <IActionResult> PutClinicStaff(long id, ClinicStaff clinicStaff)
        {
            if (id != clinicStaff.Id)
            {
                return(BadRequest());
            }

            _context.Entry(clinicStaff).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ClinicStaffExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Esempio n. 3
0
        public async Task <IActionResult> Edit(int id, [Bind("Nom,Description,Id")] Categorie categorie)
        {
            if (id != categorie.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    CliniqueDbContext context = _contextFactory.CreateDbContext();
                    context.Update(categorie);
                    await context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CategorieExists(categorie.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(categorie));
        }
Esempio n. 4
0
        public async Task <IActionResult> Edit(int id, [Bind("Rang,NomChirurgie,IdOrdonnance,Id")] Ordonnancechirurgie ordonnancechirurgie)
        {
            if (id != ordonnancechirurgie.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    CliniqueDbContext context = _contextFactory.CreateDbContext();
                    context.Update(ordonnancechirurgie);
                    await context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!OrdonnancechirurgieExists(ordonnancechirurgie.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["IdOrdonnance"] = new SelectList(_contextFactory.CreateDbContext().Ordonnances, "Id", "Id", ordonnancechirurgie.IdOrdonnance);
            return(View(ordonnancechirurgie));
        }
Esempio n. 5
0
        public async Task <IActionResult> Edit(int id, [Bind("Matricule,NomM,PrenomM,IdSpecialite,Ville,Adresse,Niveau,NbrPatients,Id")] Docteur docteur)
        {
            if (id != docteur.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    CliniqueDbContext context = _contextFactory.CreateDbContext();
                    context.Update(docteur);
                    await context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DocteurExists(docteur.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["IdSpecialite"] = new SelectList(_contextFactory.CreateDbContext().Specialites, "Id", "Titre", docteur.IdSpecialite);
            return(View(docteur));
        }
Esempio n. 6
0
        public async Task <IActionResult> Edit(int id, [Bind("NomMed,Prix,IdCategorie,Id")] Medicament medicament)
        {
            if (id != medicament.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    CliniqueDbContext context = _contextFactory.CreateDbContext();
                    context.Update(medicament);
                    await context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MedicamentExists(medicament.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["IdCategorie"] = new SelectList(_contextFactory.CreateDbContext().Categories, "Id", "Id", medicament.IdCategorie);
            return(View(medicament));
        }
Esempio n. 7
0
        public async Task <IActionResult> Edit(int id, [Bind("Recommandations,TypeO,DateC,Id")] Ordonnance ordonnance)
        {
            if (id != ordonnance.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    CliniqueDbContext context = _contextFactory.CreateDbContext();
                    context.Update(ordonnance);
                    await context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!OrdonnanceExists(ordonnance.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(ordonnance));
        }
        public async Task <ActionResult <AppointmentDto> > PostAppointment(AppointmentDto appointment)
        {
            var staffId        = appointment.StaffId;
            var userId         = int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value);
            var newAppointment = await _context.Appointments
                                 .FirstOrDefaultAsync(app => app.AppointmentTime == appointment.AppointmentTime && app.ClinicStaff.Id == staffId ||
                                                      app.UserId == userId && app.AppointmentTime == appointment.AppointmentTime);

            if (newAppointment != null)
            {
                return(BadRequest("An appointment already exists!"));
            }
            newAppointment = new Appointment
            {
                UserId          = userId,
                ClinicStaffId   = staffId,
                Reason          = appointment.Reason,
                AppointmentTime = appointment.AppointmentTime
            };
            await _context.Appointments.AddAsync(newAppointment);

            if (await _context.SaveChangesAsync() > 0)
            {
                return(Ok());
            }

            return(BadRequest("Failed to make an appointment"));
        }
Esempio n. 9
0
        public async Task <IActionResult> Edit(int id, [Bind("NomP,PrenomP,Genre,NumAS,DateNaiss,DateC,IdDocteur,Id")] Dossierpatient dossierpatient)
        {
            if (id != dossierpatient.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    CliniqueDbContext context = _contextFactory.CreateDbContext();
                    context.Update(dossierpatient);
                    await context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DossierpatientExists(dossierpatient.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["Genre"]     = new SelectList(Enum.GetNames(typeof(Genre)));
            ViewData["IdDocteur"] = new SelectList(_contextFactory.CreateDbContext().Docteurs, "Id", "NomM", dossierpatient.IdDocteur);
            return(View(dossierpatient));
        }
Esempio n. 10
0
        public async Task <IActionResult> Edit(int id, [Bind("IdDocteur,IdDossierpatient,DateC,Diagnostic,IdOrdonnance,Id")] Consultation consultation)
        {
            if (id != consultation.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    CliniqueDbContext context = _contextFactory.CreateDbContext();
                    context.Update(consultation);
                    await context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ConsultationExists(consultation.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(consultation));
        }
Esempio n. 11
0
        public async Task <IActionResult> Edit(int id, [Bind("Subject,Description,Start,End,ThemeColor,IsFullDay,IdDocteur,IdDossierpatient,Id")] RendezVous rendezVous)
        {
            if (id != rendezVous.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    CliniqueDbContext context = _contextFactory.CreateDbContext();
                    context.Update(rendezVous);
                    await context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!RendezVousExists(rendezVous.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["Couleurs"]  = Couleur.CreerSelectList();
            ViewData["IdDocteur"] = new SelectList(_contextFactory.CreateDbContext().Docteurs, "Id", "NomComplet", rendezVous.IdDocteur);
            ViewData["IdDossier"] = new SelectList(_contextFactory.CreateDbContext().Dossierpatients, "Id", "NomComplet", rendezVous.IdDossierpatient);
            return(View(rendezVous));
        }
Esempio n. 12
0
        public async Task <IActionResult> DeleteConfirmed(int id)
        {
            CliniqueDbContext context = _contextFactory.CreateDbContext();
            var ordonnance            = await context.Ordonnances.FindAsync(id);

            context.Ordonnances.Remove(ordonnance);
            await context.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }
Esempio n. 13
0
        public async Task <IActionResult> DeleteConfirmed(int id)
        {
            CliniqueDbContext context = _contextFactory.CreateDbContext();
            var dossierpatient        = await context.Dossierpatients.FindAsync(id);

            context.Dossierpatients.Remove(dossierpatient);
            await context.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }
Esempio n. 14
0
        public async Task <T> Create(T entity)
        {
            using (CliniqueDbContext context = _contextFactory.CreateDbContext())
            {
                EntityEntry <T> createdResult = await context.Set <T>().AddAsync(entity);

                await context.SaveChangesAsync();

                return(createdResult.Entity);
            }
        }
Esempio n. 15
0
        public async Task <bool> Delete(DateTime datec, int iddocteur, int iddossierpatient)
        {
            using (CliniqueDbContext context = _contextFactory.CreateDbContext())
            {
                Consultation entity = await context.Set <Consultation>().FirstOrDefaultAsync((e) => e.IdDocteur == iddocteur && e.IdDossierpatient == iddossierpatient && e.DateC == datec);

                await context.SaveChangesAsync();

                return(true);
            }
        }
Esempio n. 16
0
        public async Task <IActionResult> Create([Bind("Recommandations,TypeO,DateC,Id")] Ordonnance ordonnance)
        {
            if (ModelState.IsValid)
            {
                CliniqueDbContext context = _contextFactory.CreateDbContext();
                context.Add(ordonnance);
                await context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(ordonnance));
        }
Esempio n. 17
0
        public async Task <IActionResult> Create([Bind("IdDocteur,IdDossierpatient,DateC,Diagnostic,IdOrdonnance,Id")] Consultation consultation)
        {
            if (ModelState.IsValid)
            {
                CliniqueDbContext context = _contextFactory.CreateDbContext();
                context.Add(consultation);
                await context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(consultation));
        }
Esempio n. 18
0
        public async Task <T> Update(int id, T entity)
        {
            using (CliniqueDbContext context = _contextFactory.CreateDbContext())
            {
                entity.Id = id;

                context.Set <T>().Update(entity);
                await context.SaveChangesAsync();

                return(entity);
            }
        }
Esempio n. 19
0
        public async Task <IActionResult> Create([Bind("Nom,Description,Id")] Categorie categorie)
        {
            if (ModelState.IsValid)
            {
                CliniqueDbContext context = _contextFactory.CreateDbContext();
                context.Add(categorie);
                await context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(categorie));
        }
Esempio n. 20
0
        public async Task <bool> Delete(int id)
        {
            using (CliniqueDbContext context = _contextFactory.CreateDbContext())
            {
                T entity = await context.Set <T>().FirstOrDefaultAsync((e) => e.Id == id);

                context.Set <T>().Remove(entity);
                await context.SaveChangesAsync();

                return(true);
            }
        }
Esempio n. 21
0
        public async Task <IActionResult> Create([Bind("Matricule,NomM,PrenomM,IdSpecialite,Ville,Adresse,Niveau,NbrPatients,Id")] Docteur docteur)
        {
            if (ModelState.IsValid)
            {
                CliniqueDbContext context = _contextFactory.CreateDbContext();
                context.Add(docteur);
                await context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["IdSpecialite"] = new SelectList(_contextFactory.CreateDbContext().Specialites, "Id", "Titre", docteur.IdSpecialite);
            return(View(docteur));
        }
Esempio n. 22
0
        public async Task <IActionResult> Create([Bind("NomMed,Prix,IdCategorie,Id")] Medicament medicament)
        {
            if (ModelState.IsValid)
            {
                CliniqueDbContext context = _contextFactory.CreateDbContext();
                context.Add(medicament);
                await context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["IdCategorie"] = new SelectList(_contextFactory.CreateDbContext().Categories, "Id", "Nom", medicament.IdCategorie);
            return(View(medicament));
        }
Esempio n. 23
0
        public async Task <Consultation> Update(DateTime datec, int iddocteur, int iddossierpatient, Consultation entity)
        {
            using (CliniqueDbContext context = _contextFactory.CreateDbContext())
            {
                entity.DateC            = datec;
                entity.IdDocteur        = iddocteur;
                entity.IdDossierpatient = iddossierpatient;
                context.Set <Consultation>().Update(entity);
                await context.SaveChangesAsync();

                return(entity);
            }
        }
Esempio n. 24
0
        public async Task <IActionResult> Create([Bind("Rang,NomChirurgie,IdOrdonnance,Id")] Ordonnancechirurgie ordonnancechirurgie)
        {
            if (ModelState.IsValid)
            {
                CliniqueDbContext context = _contextFactory.CreateDbContext();
                context.Add(ordonnancechirurgie);
                await context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["IdOrdonnance"] = new SelectList(_contextFactory.CreateDbContext().Ordonnances, "Id", "Id", ordonnancechirurgie.IdOrdonnance);
            return(View(ordonnancechirurgie));
        }
Esempio n. 25
0
        public async Task <IActionResult> Create([Bind("NomP,PrenomP,Genre,NumAS,DateNaiss,DateC,IdDocteur,Id")] Dossierpatient dossierpatient)
        {
            if (ModelState.IsValid)
            {
                CliniqueDbContext context = _contextFactory.CreateDbContext();
                context.Add(dossierpatient);
                await context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["Genre"]     = new SelectList(Enum.GetNames(typeof(Genre)));
            ViewData["IdDocteur"] = new SelectList(_contextFactory.CreateDbContext().Docteurs, "Id", "NomM", dossierpatient.IdDocteur);
            return(View(dossierpatient));
        }
Esempio n. 26
0
        public async Task <IActionResult> Create([Bind("NbBoites,IdOrdonnance,IdMedicament,Id")] Ordonnancemedicament ordonnancemedicament)
        {
            if (ModelState.IsValid)
            {
                CliniqueDbContext context = _contextFactory.CreateDbContext();
                context.Add(ordonnancemedicament);
                await context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["IdMedicament"] = new SelectList(_contextFactory.CreateDbContext().Medicaments, "Id", "NomMed", ordonnancemedicament.IdMedicament);
            ViewData["IdOrdonnance"] = new SelectList(_contextFactory.CreateDbContext().Ordonnances, "Id", "Id", ordonnancemedicament.IdOrdonnance);
            return(View(ordonnancemedicament));
        }
Esempio n. 27
0
        public async Task <IActionResult> Create([Bind("Subject,Description,Start,End,ThemeColor,IdDocteur,IdDossierpatient,Id")] RendezVous rendezVous)
        {
            if (ModelState.IsValid)
            {
                CliniqueDbContext context = _contextFactory.CreateDbContext();
                context.Add(rendezVous);
                await context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["Couleurs"]  = Couleur.CreerSelectList();
            ViewData["IdDocteur"] = new SelectList(_contextFactory.CreateDbContext().Docteurs, "Id", "NomComplet", rendezVous.IdDocteur);
            ViewData["IdDossier"] = new SelectList(_contextFactory.CreateDbContext().Dossierpatients, "Id", "NomComplet", rendezVous.IdDossierpatient);
            return(View(rendezVous));
        }