Esempio n. 1
0
        private Clinic_Subspecialty CreateSubspecialty(string description, Clinic_Specialty specialty, uint consultationLength, Clinic clinic)
        {
            Clinic_Subspecialty subspecialty;

            using (var dbContext = new ApplicationDbContext())
            {
                var subspecialtyData = dbContext.Subspecialties.FirstOrDefault(sp => sp.Description == description);

                if (subspecialtyData == null)
                {
                    subspecialtyData = new SubspecialtyData
                    {
                        Description     = description,
                        SpecialtyDataId = specialty.DataId
                    };

                    dbContext.Subspecialties.Add(subspecialtyData);
                }

                dbContext.SaveChanges();

                subspecialty = new Clinic_Subspecialty
                {
                    DataId             = subspecialtyData.Id,
                    SpecialtyId        = specialty.Id,
                    ConsultationLength = consultationLength,
                    UserId             = clinic.UserId
                };

                dbContext.Clinic_Subspecialties.Add(subspecialty);
                dbContext.SaveChanges();
            }

            return(subspecialty);
        }
Esempio n. 2
0
        private Clinic_Specialty CreateSpecialty(string description, Clinic clinic)
        {
            Clinic_Specialty specialty;

            using (var dbContext = new ApplicationDbContext())
            {
                var specialtyData = dbContext.Specialties.FirstOrDefault(s => s.Description == description);

                if (specialtyData == null)
                {
                    specialtyData = new SpecialtyData
                    {
                        Description = description
                    };

                    dbContext.Specialties.Add(specialtyData);
                }

                dbContext.SaveChanges();

                specialty = new Clinic_Specialty
                {
                    DataId = specialtyData.Id,
                    UserId = clinic.UserId
                };

                dbContext.Clinic_Specialties.Add(specialty);
                dbContext.SaveChanges();
            }

            return(specialty);
        }
Esempio n. 3
0
        private Clinic_Doctor CreateDoctor(string firstName, string lastName, uint consultationLength, Clinic_Specialty specialty, Clinic_Subspecialty subspecialty, DoctorStateEnum state, List <Clinic_WorkingHours> workingHours, Clinic clinic)
        {
            Clinic_Doctor doctor;

            using (var dbContext = new ApplicationDbContext())
            {
                doctor = new Clinic_Doctor
                {
                    FirstName          = firstName,
                    LastName           = lastName,
                    PhoneNumber        = string.Empty,
                    Email              = string.Empty,
                    ConsultationLength = consultationLength,
                    SpecialtyId        = specialty.Id,
                    SubspecialtyId     = subspecialty?.Id,
                    State              = state,
                    WorkingHours       = workingHours,
                    UserId             = clinic.UserId
                };

                dbContext.Clinic_Doctors.Add(doctor);
                dbContext.SaveChanges();
            }

            return(doctor);
        }