Exemple #1
0
        public async Task <IActionResult> Create([Bind("InterventionID,PreInterventionScore,PostInterventionScore,Antecedence,Behaviours,Consequence,Treatment")] Intervention intervention)
        {
            if (ModelState.IsValid)
            {
                _context.Add(intervention);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(intervention));
        }
        public async Task <IActionResult> Create([Bind("DoctorId,FirstName,LastName,Degree,OfficeNumber,HireDate")] Doctors doctors)
        {
            if (ModelState.IsValid)
            {
                _context.Add(doctors);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(doctors));
        }
        public async Task <IActionResult> Create([Bind("HealthCareProviderID,Name,ContactNumber")] HealthCareProvider healthCareProvider)
        {
            if (ModelState.IsValid)
            {
                _context.Add(healthCareProvider);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(healthCareProvider));
        }
        public async Task <IActionResult> Create([Bind("PractitionerID,Username,Password,Email,Type,ContactNo")] Practitioner practitioner)
        {
            if (ModelState.IsValid)
            {
                _context.Add(practitioner);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(practitioner));
        }
        public async Task <IActionResult> Create([Bind("PatientID,PatientFirstname,PatientLastname,Email,ContactNo,Username,Password")] Patient patient)
        {
            if (ModelState.IsValid)
            {
                _context.Add(patient);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(patient));
        }
        public async Task <IActionResult> Create([Bind("ProcedureID,PatientID,PractitionerID,ProcedureDate,Medication,followupDate,Complication,ProcedureUsed")] Procedure procedure)
        {
            if (ModelState.IsValid)
            {
                _context.Add(procedure);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(procedure));
        }
Exemple #7
0
        public async Task <IActionResult> Create([Bind("Id,PatientId,FirstName,LastName,ScheduledDate,HealthInsurance")] Patients patients)
        {
            if (ModelState.IsValid)
            {
                _context.Add(patients);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(patients));
        }
Exemple #8
0
        public async Task <IActionResult> Create([Bind("PersonId,FirstName,LastName")] Client client)
        {
            if (ModelState.IsValid)
            {
                _context.Add(client);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(client));
        }
Exemple #9
0
        public async Task <IActionResult> Create([Bind("ClientID,NiNumber,FirstName,Lastname,DateOfBirth,ContactNumber,Email,AddressLine1,AddressLine2,AddressLine3,ReferredBy,Subscriber,ClientNotes,Medications,SoFirstName,SoLastName,SoRelationship,SoContactNumber")] Client client)
        {
            if (ModelState.IsValid)
            {
                _context.Add(client);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(client));
        }
        public async Task <IActionResult> Create([Bind("SessionID,SessionTime,IsAccompanied,IsDelivered,CancelledBy,InterventionID")] Session session)
        {
            if (ModelState.IsValid)
            {
                _context.Add(session);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["InterventionID"] = new SelectList(_context.Interventions, "InterventionID", "InterventionID", session.InterventionID);
            return(View(session));
        }
Exemple #11
0
        public async Task <IActionResult> Create([Bind("HireDate,EmployeeTypeId,PersonId,FirstName,LastName")] Employee employee)
        {
            if (ModelState.IsValid)
            {
                _context.Add(employee);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["EmployeeTypeId"] = new SelectList(_context.EmployeeTypes, "EmployeeTypeId", "Name", employee.EmployeeTypeId);
            return(View(employee));
        }
Exemple #12
0
        public async Task <IActionResult> Create([Bind("TermID,Category,Date,Priority,DoctorId")] Terms terms)
        {
            if (ModelState.IsValid)
            {
                _context.Add(terms);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DoctorId"] = new SelectList(_context.Doctors, "DoctorId", "FullName", terms.DoctorId);
            return(View(terms));
        }
        public async Task <IActionResult> Create([Bind("PersonAddressId,PersonId,AddressLine1,AddressLine2,City,State,PostalCode")] PersonAddress personAddress)
        {
            if (ModelState.IsValid)
            {
                _context.Add(personAddress);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Details", "Clients", new { id = personAddress.PersonId }, null));
            }
            ViewData["PersonId"] = new SelectList(_context.Persons, "PersonId", "FullName", personAddress.PersonId);
            return(View(personAddress));
        }
Exemple #14
0
        public async Task <IActionResult> Create([Bind("PersonEmailId,PersonId,EmailAddress")] PersonEmail personEmail)
        {
            if (ModelState.IsValid)
            {
                _context.Add(personEmail);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Details", "Clients", new { id = personEmail.PersonId }, null));
            }
            ViewData["PersonId"] = new SelectList(_context.Persons, "PersonId", "FirstName", personEmail.PersonId);
            return(View(personEmail));
        }
Exemple #15
0
        public async Task <IActionResult> Create([Bind("ClientAnimalId,ClientId,SpeciesId,Name,BirthDate,Notes")] ClientAnimal clientAnimal)
        {
            if (ModelState.IsValid)
            {
                _context.Add(clientAnimal);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Details", "Clients", new { id = clientAnimal.ClientId }, null));
            }
            ViewData["ClientId"]  = new SelectList(_context.Clients, "PersonId", "FullName", clientAnimal.ClientId);
            ViewData["SpeciesId"] = new SelectList(_context.Species, "SpeciesId", "Name", clientAnimal.SpeciesId);
            return(View(clientAnimal));
        }
        public async Task <IActionResult> Create([Bind("AppointmentId,ClientAnimalId,EmployeeId,AppointmentDate,Reason")] Appointment appointment)
        {
            if (ModelState.IsValid)
            {
                _context.Add(appointment);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ClientAnimalId"] = new SelectList(_context.ClientAnimals, "ClientAnimalId", "Name", appointment.ClientAnimalId);
            ViewData["EmployeeId"]     = new SelectList(_context.Employees, "PersonId", "FullName", appointment.EmployeeId);
            return(View(appointment));
        }
        public async Task <IActionResult> Create([Bind("ScheduleID,TermID,PatientID,Diagnose")] Scheduling scheduling)
        {
            if (ModelState.IsValid)
            {
                _context.Add(scheduling);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["PatientID"] = new SelectList(_context.Patients, "Id", "FirstName", scheduling.PatientID);
            ViewData["TermID"]    = new SelectList(_context.Terms, "TermID", "Category", scheduling.TermID);
            return(View(scheduling));
        }
Exemple #18
0
 public IActionResult CreateClinic([FromBody] Clinic clinic)
 {
     try
     {
         _clinicContext.Add(clinic);
         _clinicContext.SaveChanges();
         return(Ok("Clinic successfully created."));
     }
     catch
     {
         return(StatusCode(500, "Clinic could not be created."));
     }
 }
        public async Task <IActionResult> Create([Bind("AppointmentID,PatientID,PractitionerID,AppointmentDate,AppointmentDescr")] Appointment appointment)
        {
            if (AppointmentDateExist(appointment.AppointmentDate))
            {
                ViewBag.Error = "The slot is already booked";
                return(View());
            }
            if (ModelState.IsValid)
            {
                _context.Add(appointment);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(appointment));
        }
Exemple #20
0
        public async Task <IActionResult> Create([Bind("PatientProfileId,DoctorId,Description,TotalCost,TreatmentDate")] PatientRecord patientRecord)
        {
            if (ModelState.IsValid)
            {
                if (_context.PatientProfiles.Any(p => p.Id == patientRecord.PatientProfileId))
                {
                    //patientRecord.PatientProfileId = patientRecord.PatientProfileId;
                    _context.Add(patientRecord);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction("Details", "Profiles", new { id = patientRecord.PatientProfileId }));
                }
            }
            ViewData["DoctorId"] = new SelectList(_context.Doctors, "Id", "Id", patientRecord.DoctorId);
            var profile = await _context.PatientProfiles.SingleOrDefaultAsync(p => p.Id == patientRecord.PatientProfileId);

            var record = new PatientRecord
            {
                PatientProfileId = patientRecord.PatientProfileId,
                Profile          = profile
            };

            return(View(record));
        }
Exemple #21
0
        public async Task <IActionResult> Create([Bind("PatientRecordId,Description,DoctorId,PaidAmount,TreatmentDate")] Treatment treatment)
        {
            if (ModelState.IsValid)
            {
                if (treatment.PatientRecordId <= 0 || !_context.PatientRecords.Any(t => t.Id == treatment.PatientRecordId))
                {
                    return(View(treatment));
                }
                treatment.UpdatedOn = DateTime.Now;
                _context.Add(treatment);

                await _context.SaveChangesAsync();

                return(RedirectToAction("Details", "Records", new { id = treatment.PatientRecordId }));
            }
            ViewData["DoctorId"] = new SelectList(_context.Doctors, "Id", "Name", treatment.DoctorId);
            //var record = await _context.PatientRecords.SingleOrDefaultAsync(r => r.Id == treatment.PatientRecordId);
            //var newTreatment = new Treatment
            //{
            //    PatientRecordId = treatment.PatientRecordId,
            //    Record = record
            //};
            return(View(treatment));
        }
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            //entity framework tutorial
            //Select all rows from Doctors table
            using (var context = new ClinicContext())
            {
                var doctors = context.Doctors.ToList();

                foreach (var obj in doctors)
                {
                    Console.WriteLine("Doctors name: " + obj.Dname + "\nCode: " + obj.Dcode + "\nSpecialty: " + obj.Specialtycode + "\n\n");
                }
            }

            //Doctors table JOIN with Specialty
            using (var context2 = new ClinicContext())
            {
                var resultWithSpecialty = context2.Doctors
                                          .Join(
                    context2.Specialties,
                    doc => doc.Specialtycode,
                    spe => spe.Scode2,
                    (doc, spe) => new
                {
                    DoctorName = doc.Dname,
                    DoctorCode = doc.Dcode,
                    Specialty  = spe.Description
                }
                    );
                foreach (var obj in resultWithSpecialty)
                {
                    Console.WriteLine("Doctors name: " + obj.DoctorName + "\nCode: " + obj.DoctorCode + "\nSpecialty: " + obj.Specialty + "\n\n");
                }
            }

            //CRUD Functionality EntityFramework
            //CREATE
            using (var ctx3 = new ClinicContext())
            {
                var newDoctor = new Doctor()
                {
                    Dcode         = "4",
                    Dname         = "Davit",
                    Specialtycode = "A3"
                };
                //INSERT
                ctx3.Add(newDoctor);
                ctx3.SaveChanges();
            }

            //UPDATE
            using (var ctx4 = new ClinicContext())
            {
                var updateDoctor = ctx4.Doctors.SingleOrDefault(d => d.Dcode == "4");
                if (updateDoctor != null)
                {
                    try
                    {
                        updateDoctor.Dname = "Davit G";
                        ctx4.SaveChanges();
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace.ToString());
                    }
                }
                else
                {
                    Console.WriteLine("Doctor id not found");
                }
            }

            //DELETE
            using (var ctx5 = new ClinicContext())
            {
                var deleteDoctor = ctx5.Doctors.SingleOrDefault(d => d.Dcode == "4");
                if (deleteDoctor != null)
                {
                    try
                    {
                        ctx5.Doctors.Remove(deleteDoctor);
                        ctx5.SaveChanges();
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace.ToString());
                    }
                }
            }

            var Reader       = new StreamReader(File.OpenRead("C:\\Users\\Christos\\Desktop\\doctorsUpload.csv"));
            var listDocNames = new List <String>();
            var listDocCodes = new List <String>();

            while (!Reader.EndOfStream)
            {
                var line   = Reader.ReadLine();
                var values = line.Split(',');

                listDocNames.Add(values[0]);
                listDocCodes.Add(values[1]);
            }

            foreach (var x in listDocNames)
            {
                Console.WriteLine(x);
            }

            foreach (var y in listDocCodes)
            {
                Console.WriteLine(y);
            }

            using (var ctx6 = new ClinicContext())
            {
                var allItems = ctx6.Doctors.Select(x => x.Dcode).ToList();
                Console.WriteLine("All items");
                foreach (var x in allItems)
                {
                    Console.WriteLine(x);
                }

                var failedItems = ctx6.Doctors.Where(x => !listDocCodes.Contains(x.Dcode)).ToList();

                Console.WriteLine("Failed items");
                foreach (var x in failedItems)
                {
                    Console.WriteLine(x.Dcode);
                }
            }
        }