// save public async Task SaveSchedule(ScheduleViewModel model) { var resultchecked = await CheckScheduleExist(model.DoctorId, model.Date); if (resultchecked == null) { var @doctorSchedule = new DoctorSchedule().Create(model.DoctorId, model.Date); var result = await _unitOfWork.DoctorScheduleRepository.CreateAndSave(@doctorSchedule); var @doctorSchedulenew = new Appoiment().Create(model.Date, model.FromTime, model.ToTime, false, model.DoctorId, model.PatientId, model.Charges, result.Id); await _unitOfWork.AppoimentRepository.CreateAndSave(@doctorSchedulenew); } else { var @doctorSchedule = new Appoiment().Create(model.Date, model.FromTime, model.ToTime, false, model.DoctorId, model.PatientId, model.Charges, resultchecked.Id); await _unitOfWork.AppoimentRepository.CreateAndSave(@doctorSchedule); } }
private void DeleteAppoiment(object obj) { if (SelectedAppoiment != null) { var context = new MedicalDBEntities(); var query = context.Appoiments .Where(s => s.idAppoiment == SelectedAppoiment.AppoimentId) .FirstOrDefault <Appoiment>(); Appoiment ap = query; var appoiments = context.Appoiments; _dataSource.Remove(SelectedAppoiment); appoiments.Remove(ap); context.SaveChanges(); MessageBox.Show("Programare stearsa cu succes"); } else { MessageBox.Show("Va rugam selectati programarea pe care doriti sa o stergeti"); } }
private void AddAppoiment(object obj) { using (var context = new MedicalDBEntities()) { CustomPrincipal customPrincipal = Thread.CurrentPrincipal as CustomPrincipal; string currentEmail = customPrincipal.Identity.Email; var query = context.Users .Where(s => s.email == currentEmail) .FirstOrDefault <User>(); var currentUser = query; Appoiment ap = new Appoiment(); if (SelectedDate != null && SelectedSpecialization != null && SelectedService != null && SelectedStartHour.ToString() != null) { ap.idUser = query.idUser; ap.idService = SelectedService.idService; ap.idDoctor = SelectedDoctor.Key; ap.date = SelectedDate; ap.startTime = SelectedStartHour; context.Appoiments.Add(ap); context.SaveChanges(); MessageBox.Show("Programare realizata cu succes"); _selectedDate = DateTime.Today.AddDays(1); NotifyPropertyChanged("SelectedDate"); _selectedSpecialization = null; NotifyPropertyChanged("SelectedSpecialization"); SelectedService = null; NotifyPropertyChanged("SelectedService"); _selectedStartHour = 0; NotifyPropertyChanged("SelectedStartHour"); } else { MessageBox.Show("Introduceti toate datele!"); } } }