public void DrugDescriptionChanged(string drugName, string description) { if (description is null) { throw new ArgumentNullException(String.Format("{0} is null", nameof(description))); } if (drugName is null) { throw new ArgumentNullException(String.Format("{0} is null", nameof(drugName))); } using (var context = new PolyclinicDBContext()) { IQueryable query = context.Drug; var drugs = from d in context.Drug where d.DrugName == drugName select d; var list = drugs.ToList(); list[0].Description = description; context.SaveChanges(); } }
public void CheckStreets(string streetName, int regionNumber) { if (streetName is null) { throw new ArgumentNullException(String.Format("{0} is null", nameof(streetName))); } bool exists = false; using (var context = new PolyclinicDBContext()) { IQueryable <Street> streetQuery = context.Street; List <Street> streets = streetQuery.ToList(); foreach (Street street in streets) { if (streetName == street.StreetName && regionNumber == street.RegionNumber) { exists = true; break; } } if (!exists) { context.Street.Add(new Street() { RegionNumber = regionNumber, StreetName = streetName }); } context.SaveChanges(); } }
public void DiagnosisAdd(string diagnosisName, string description) { if (description is null) { throw new ArgumentNullException(String.Format("{0} is null", nameof(description))); } if (diagnosisName is null) { throw new ArgumentNullException(String.Format("{0} is null", nameof(diagnosisName))); } using (var context = new PolyclinicDBContext()) { IQueryable query = context.Diagnosis; Diagnosis diagnosis = new Diagnosis() { DiagnosisName = diagnosisName, Description = description, }; context.Diagnosis.Add(diagnosis); context.SaveChanges(); } }
public void DrugAdd(string drugName, string description) { if (description is null) { throw new ArgumentNullException(String.Format("{0} is null", nameof(description))); } if (drugName is null) { throw new ArgumentNullException(String.Format("{0} is null", nameof(drugName))); } using (var context = new PolyclinicDBContext()) { IQueryable query = context.Drug; Drug drug = new Drug() { DrugName = drugName, Description = description, }; context.Drug.Add(drug); context.SaveChanges(); } }
public void DeleteOldTickets() { List <Ticket> OldTickets = GetOldTickets(); using (var context = new PolyclinicDBContext()) { foreach (Ticket ticket in OldTickets) { context.Ticket.Attach(ticket); context.Ticket.Remove(ticket); } context.SaveChanges(); } }
public void AddTicketToStorage(int patientsId, int doctorsId, DateTime visitingDate) { using (var context = new PolyclinicDBContext()) { IQueryable query = context.Ticket; Ticket ticket = new Ticket(); ticket.PatientsId = patientsId; ticket.DoctorsId = doctorsId; ticket.VisitingDateAndTime = visitingDate; ticket.IsArrived = false; context.Ticket.Add(ticket); context.SaveChanges(); } }
public void DoctorCreate(PolyclinicBL.Doctor doctor) { using (var context = new PolyclinicDBContext()) { Doctor newDoctor = new Doctor(); newDoctor.LastName = doctor.LastName; newDoctor.FirstName = doctor.FirstName; newDoctor.Patronymic = doctor.Patronymic; newDoctor.Specialization = doctor.Specialization; newDoctor.Region = doctor.Region; newDoctor.Room = doctor.Room; newDoctor.Shedule = doctor.Schedule; newDoctor.Interval = doctor.Interval; context.Doctor.Add(newDoctor); context.SaveChanges(); } }
public void AddNewSpecialization(string specializationName) { if (specializationName is null) { throw new ArgumentNullException(String.Format("{0} is null", nameof(specializationName))); } using (var context = new PolyclinicDBContext()) { Specialization specialization = new Specialization { SpecializationName = specializationName }; context.Specialization.Add(specialization); context.SaveChanges(); } }
public void AddNewSchedule(int specializationId, string schedule, int interval) { if (schedule is null) { throw new ArgumentNullException(String.Format("{0} is null", nameof(schedule))); } using (var context = new PolyclinicDBContext()) { DoctorsTimeTable doctorsTimeTable = new DoctorsTimeTable() { SpecId = specializationId, Shedule = schedule, Interval = interval }; context.DoctorsTimeTable.Add(doctorsTimeTable); context.SaveChanges(); } }
public void AddNewDoctorsSchedule(int doctorsId, string schedule, int interval) { if (schedule is null) { throw new ArgumentNullException(String.Format("{0} is null", nameof(schedule))); } using (var context = new PolyclinicDBContext()) { var doctors = from d in context.Doctor where d.DocId == doctorsId select d; Doctor doctor = doctors.ToList()[0]; doctor.Shedule = schedule; doctor.Interval = interval; context.Entry(doctor).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); } }
public void AddNewRegion(int regionId, string regionName, string streetName) { using (var context = new PolyclinicDBContext()) { var regions = from r in context.Region where r.RegionNumber == regionId select r; if (regions.ToList().Count == 0) { Region region = new Region { RegionNumber = regionId, RegionName = regionName }; context.Region.Add(region); } var streets = from s in context.Street where s.RegionNumber == regionId where s.StreetName == streetName select s; if (streets.ToList().Count == 0) { Street street = new Street { RegionNumber = regionId, StreetName = streetName, }; context.Street.Add(street); } context.SaveChanges(); } }