public RegularAppointmentService() { appointmentRepository = new AppointmentRepository(path); doctorController = new DoctorController(); employeesScheduleController = new EmployeesScheduleController(); patientController = new PatientController(); }
public void Given_AppointmentRepository_When_EditingAnAppointment_Then_TheAppointmentShouldBeProperlyEdited() { RunOnDatabase(async ctx => { //Arrange var repository = new AppointmentRepository(ctx); var patient = Patient.Create("1234", "Roland", "Iordache", "*****@*****.**", "asfdsdssd", "Iasi", "Romania", new DateTime(1996, 02, 10), "0746524459", null); var patient2 = Patient.Create("1234", "Roland", "Iordache2", "*****@*****.**", "asfdsdssd", "Iasi", "Romania", new DateTime(1996, 02, 10), "0746524459", null); var doctor = Doctor.Create("1234", "Mircea", "Cartarescu", "*****@*****.**", "parola", "0746524459", "blasdadsadsada", "Cardiologie", "Sf. Spiridon", "Iasi", "Romania", "Str. Vasile Lupu", true); var appointmentInterval = AppointmentInterval.Create(3, new TimeSpan(0, 10, 0, 0), new TimeSpan(0, 11, 0, 0), doctor.DoctorId); var appointment = Appointment.Create(appointmentInterval.AppointmentIntervalId, new DateTime(1996, 02, 10), doctor.DoctorId, patient.PatientId); await repository.AddAsync(appointment); var appointmentPatient = appointment.Patient; appointment.Update(appointmentInterval.AppointmentIntervalId, new DateTime(1996, 02, 10), doctor.DoctorId, patient2.PatientId, appointment.HaveFeedback, appointment.HaveMedicalHistory); //Act await repository.UpdateAsync(appointment); //Assert Assert.AreNotEqual(appointmentPatient, appointment.Patient); }); }
public UnitOfWork(TamirhaneContext context) { _tamirhaneContext = context; UserRepository = new UserRepository(_tamirhaneContext); CarRepository = new CarRepository(_tamirhaneContext); AppointmentRepository = new AppointmentRepository(_tamirhaneContext); }
public new ActionResult Request(AppointmentRequest model) { if (!ModelState.IsValid) { return(View(model)); } Appointment app = new Appointment() { ID = model.ID, Date = model.Date, DoctorID = model.DoctorID, PatientID = AuthenticationManager.LoggedUser.ID }; AppointmentRepository appRepo = new AppointmentRepository(); // check if appointment already exists Appointment findApp = appRepo.GetFirst(a => (app.Date >= a.Date && app.Date <= DbFunctions.AddMinutes(a.Date, 30)) && app.DoctorID == a.DoctorID); if (findApp == null) { appRepo.Save(app); } else { ModelState.AddModelError(string.Empty, "There is already an appointment scheduled for this date and hour!"); return(View(model)); } return(RedirectToAction("Index")); }
public ActionResult Review(AppointmentReview model) { if (!ModelState.IsValid) { return(View(model)); } AppointmentRepository appRepo = new AppointmentRepository(); Appointment app = appRepo.GetByID(model.ID); if (Request.Form["Approve"] != null) { model = Approve(model); } else if (Request.Form["Decline"] != null) { model = Decline(model); } app.Status = model.Status; appRepo.Save(app); return(RedirectToAction("Index")); }
public void CanAppointmentRepositoryAdd() { // arrange var mockSpaContext = new Mock <SpaContext>(new DbContextOptionsBuilder <SpaContext>().Options); var mockReadOnlyContext = new Mock <IReadOnlySpaContext>(); AppointmentRepository repo = new AppointmentRepository(mockSpaContext.Object, mockReadOnlyContext.Object); var testAppt = new Appointment() { AppTime = DateTime.Now, Id = 0, Description = "This is a test appointment", CustomerId = 1, ProviderId = 1 }; mockSpaContext.Setup(x => x.Appointments.Add(testAppt)); mockSpaContext.Setup(x => x.SaveChanges()); //act repo.Add(testAppt); // assert var a = repo.Appointments.FirstOrDefault(x => x.Id == testAppt.Id); Assert.NotNull(a); }
public ActionResult Create([Bind(Exclude = "SelectedActivities")] AppointmentCreateViewModel model, string[] selectedActivities) { //if (ModelState.IsValid) { AppointmentRepository repository = new AppointmentRepository(); Appointment appointment = new Appointment(); appointment.UserId = UserController.UserId; appointment.StartDateTime = model.StartDateTime; appointment.Activities = GetSelectedActivities(selectedActivities, repository); foreach (var item in appointment.Activities) { time += item.Duration; } appointment.EndDateTime = model.StartDateTime.AddHours(time); repository.Insert(appointment); return(RedirectToAction("AppointmentList")); } //else //{ // return View(model); //}\\ }
public List <Term> RecommendAppointments(DateTime startDateTime, DateTime endDateTime, Doctor doctor) { List <Term> free = AppointmentRepository.GetInstance().GetAvailableAppointmentsInSpan(startDateTime, endDateTime); if (doctor != null) { AppointmentService service = new AppointmentService(); List <Appointment> all = service.GetAppointmentsInTimeFrame(startDateTime, endDateTime, doctor, null); List <Term> ret = new List <Term>(); foreach (Term app in free) { bool x = false; foreach (Appointment appo in all) { if (DateTime.Compare(app.StartTime, appo.StartTime) == 0 && DateTime.Compare(app.EndTime, appo.EndTime) == 0) { x = true; break; } } if (!x) { ret.Add(app); } } return(ret); } return(free); }
// GET: Appointment public ActionResult AppointmentList() { AppointmentRepository appointmentRepository = new AppointmentRepository(); List <Appointment> appointments = appointmentRepository.GetAll(app => app.UserId == UserController.UserId); return(View(appointments)); }
public ActionResult Apply(int?id, AppointmentViewModel avm) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var arepo = new AppointmentRepository(new AnyHireDbContext()); try { var package = prepo.GetById(id ?? 0); var app = new Appointment(); app.Completed = false; app.Location = avm.Location; app.PackageId = package.Id; app.CustomerId = avm.uid; app.Time = Convert.ToDateTime(avm.Date + " " + avm.Time); arepo.Insert(app); arepo.Submit(); } catch (Exception e) { TempData["Error"] = e.Message.ToString(); return(Redirect("/Browse/Package/" + (id ?? 0))); } TempData["Success"] = "Appointment Scheduled!"; return(Redirect("/Browse/Package/" + (id ?? 0))); }
public AppointmentDetail(DetailMode mode, Dashboard parent, AppointmentRepository aptRepo, CustomerRepository custRepo, AddressRepository addressRepo, User loggedInUser, Appointment appointmentToModify = null) { LoggedInUser = loggedInUser; AppointmentRepo = aptRepo; CustomerRepo = custRepo; AddressRepo = addressRepo; Mode = mode; Dashboard = parent; AppointmentToModify = appointmentToModify; Customers = CustomerRepo.GetAllCustomers(); InitializeComponent(); cmbCustomer.ValueMember = "Id"; cmbCustomer.DisplayMember = "CustomerName"; cmbCustomer.DataSource = Customers; dtpBegin.Format = DateTimePickerFormat.Custom; dtpBegin.CustomFormat = "MM/dd/yyyy hh:mm tt"; dtpEnd.Format = DateTimePickerFormat.Custom; dtpEnd.CustomFormat = "MM/dd/yyyy hh:mm tt"; lblError.Visible = false; }
public void CreateAppointment() { var repo = new Mock <IRepository <Appointment> >(); // Arrange AppointmentRepository rep = new AppointmentRepository(); PeopleRepository peopleRep = new PeopleRepository(); AppointmentsController controller = new AppointmentsController(rep.Repo, peopleRep.Repo); controller.Request = new HttpRequestMessage(); controller.Configuration = new HttpConfiguration(); var testAppointment = new AppointmentDTO() { Client = new PersonDTO(peopleRep.Repo.All().FirstOrDefault(o => o.ApplicationUser.UserName == "*****@*****.**")), Collaborater = new PersonDTO(peopleRep.Repo.All().FirstOrDefault(o => o.ApplicationUser.UserName == "*****@*****.**")), StartDate = DateTime.UtcNow, EndDate = DateTime.UtcNow.AddHours(2), Status = AppointmentStatus.Pending, Note = "plata o plomo" }; // Act IHttpActionResult result = controller.Post("*****@*****.**", testAppointment); var contentResult = result as OkNegotiatedContentResult <AppointmentDTO>; // Assert Assert.IsNotNull(contentResult); Assert.IsNotNull(contentResult.Content); Assert.AreEqual(testAppointment.StartDate, contentResult.Content.StartDate); }
public UnitOfWork(ApplicationDbContext context) { _context = context; Patients = new PatientRepository(context); Appointments = new AppointmentRepository(context); Attandences = new AttendanceRepository(context); Cities = new CityRepository(context); Profesors = new ProfesorRepository(context); Specializations = new SpecializationRepository(context); Users = new ApplicationUserRepository(context); Persons = new PersonRepository(context); Faculties = new FacultyRepository(context); FacultyTypes = new FacultyTypeRepository(context); FacultySectors = new FacultySectorRepository(context); Faculties2 = new Faculty2Repository(context); Quotas = new QuotaRepository(context); PracticeTypes = new PracticeTypeRepository(context); RatingTypes = new RatingTypeRepository(context); Mentors = new MentorRepository(context); Students = new StudentRepository(context); Internships = new InternshipRepository(context); StudentInternships = new StudentInternshipRepository(context); StudentRatings = new StudentRatingRepository(context); FacultyCourses = new FacultyCourseRepository(context); Firms = new FirmRepository(context); FirmTypes = new FirmTypeRepository(context); }
public ActionResult CrudResult(ResultParams param) { DefaultSchedule result = new DefaultSchedule(); if (param.action == "insert" || (param.action == "batch" && param.added != null)) { var value = param.action == "insert" ? param.value : param.added[0]; result = AppointmentRepository.Insert(value); } if ((param.action == "batch" && param.deleted != null) || param.action == "remove") { if (param.action == "remove") { result = AppointmentRepository.Remove(Convert.ToInt32(param.key)); } else { foreach (var dele in param.deleted) { result = AppointmentRepository.Remove(Convert.ToInt32(dele.Id)); } } } if ((param.action == "batch" && param.changed != null) || param.action == "update") { var value = param.action == "update" ? param.value : param.changed[0]; result = AppointmentRepository.Update(value); } return(Json(result, JsonRequestBehavior.AllowGet)); }
private void EditAppointmentForm_Load(object sender, EventArgs e) { DefaultSettingsRepository dRepo = new DefaultSettingsRepository(); radCheckedDropDownList1.DataSource = dRepo.GetSetingsByType("price").ToList(); radCheckedDropDownList1.DisplayMember = "Name"; radCheckedDropDownList1.ValueMember = "Value"; PersianDateFormatter pdf = new PersianDateFormatter(); tTime.Format = DateTimePickerFormat.Custom; tTime.CustomFormat = "HH:mm"; tTime.ShowUpDown = true; bSave.DialogResult = DialogResult.OK; bCancel.DialogResult = DialogResult.Cancel; AppointmentRepository repo = new AppointmentRepository(); Appointment appo = repo.getAppointment(appointmentId); DateTime dt = new DateTime(2000, 1, 1, 0, 0, 0).Add(appo.AppointmentTime.Value); tTime.Value = dt; tDate.Text = pdf.convert(appo.AppointmentDate.Value); string[] parts = appo.Description.Split('/'); foreach (RadCheckedListDataItem item in radCheckedDropDownList1.Items) { if (parts.Contains(item.DisplayValue.ToString())) { item.Checked = true; unchangedValue += Convert.ToInt32(item.Value.ToString()); } } }
private void bSave_Click(object sender, EventArgs e) { PersianDateFormatter pdf = new PersianDateFormatter(); AppointmentRepository appRepo = new AppointmentRepository(); ContractRepository cRepo = new ContractRepository(); Contract contract = cRepo.getContract(contractId); Appointment app = new Appointment(); string description = ""; int value = 0; foreach (var item in radCheckedDropDownList1.CheckedItems) { description += item.DisplayValue.ToString() + "/"; value += Convert.ToInt32(item.Value); } contract.ContractPayment += value; cRepo.updateContract(contract); app.ContractId = contractId; description = description.Remove(description.Length - 1); app.Description = description; app.AppointmentDate = pdf.convert(tDate.Text); TimeSpan ts = new TimeSpan(tTime.Value.TimeOfDay.Hours, tTime.Value.TimeOfDay.Minutes, 0); app.AppointmentTime = ts; appRepo.addAppointment(app); }
public void TestInitialize() { _mockAppointment = new Mock <DbSet <Appointment> >(); _mockContext = new Mock <IApplicationDbContext>(); _repository = new AppointmentRepository(_mockContext.Object); }
public void Given_AppointmentRepository_When_EditingAnAppointment_Then_TheAppointmentShouldBeProperlyEdited() { RunOnDatabase(async ctx => { //Arrange var repository = new AppointmentRepository(ctx); var patient = Patient.Create("Roland", "Iordache", "*****@*****.**", "asfdsdssd", "Iasi", new DateTime(1996, 02, 10), "0746524459", null); var patient2 = Patient.Create("Roland", "Oana", "*****@*****.**", "asfdsdssd", "Iasi", new DateTime(1996, 02, 10), "0746524459", null); var doctor = Doctor.Create("a", "b", "*****@*****.**", "adcd", "0334123123", "ads", "ads", "dsd", "dsds", "dsds"); var appointment = Appointment.Create(new DateTime(1996, 02, 10), doctor, patient); await repository.AddAsync(appointment); var appointmentPatient = appointment.Patient; appointment.Update(new DateTime(1996, 02, 10), doctor, patient2); //Act await repository.UpdateAsync(appointment); //Assert Assert.AreNotEqual(appointmentPatient, appointment.Patient); }); }
public ActionResult Index() { var repo = new AppointmentRepository(_appSettings); var model = repo.GetAppointments(); return(View(model)); }
private void InitializeRepositories() { NhibernateInitalize.Setup(); _todorepo = new TodoRepository(NhibernateInitalize.session); _contactRepository = new ContactRepository(NhibernateInitalize.session); _appointmentRepository = new AppointmentRepository(NhibernateInitalize.session); }
public ActionResult Edit(int?id, int?doctorId) { Appointment item = null; AppointmentRepository repo = new AppointmentRepository(); item = id == null ? new Appointment() : repo.GetById(id.Value); EditVM model = item == null ? new EditVM() : new EditVM(item); PatientRepository pRepo = new PatientRepository(); List <Patient> allPatients = pRepo.GetAll(); model.PatientsList = new List <SelectListItem>(); foreach (Patient patient in allPatients) { model.PatientsList.Add( new SelectListItem() { Value = patient.Id.ToString(), Text = patient.FirstName + " " + patient.LastName, Selected = patient.Id == model.SelectedPatient } ); } if (model.Id <= 0) { model.DoctorId = doctorId.Value; } return(View(model)); }
// GET /api/PatientApp/Get public IEnumerable <patientAppoInfo> Get(string patientid, string mobile) { try { if (patientid == null) { return(null); } if (mobile == null) { return(null); } int id = 0; if (!int.TryParse(patientid, out id)) { return(null); } AppointmentRepository app = new AppointmentRepository(); IEnumerable <patientAppoInfo> patientAppoInfoList = app.getPatientAppountmenInfo(id, mobile); return(patientAppoInfoList); } catch { return(null); } }
private void radGridView3_UserDeletingRow(object sender, GridViewRowCancelEventArgs e) { DialogResult result = MessageBox.Show("آیا از عملیات حذف مطمئن هستید؟", "هشدار", MessageBoxButtons.YesNo); if (result == DialogResult.No) { e.Cancel = true; } else { int value = 0; DefaultSettingsRepository dRepo = new DefaultSettingsRepository(); ContractRepository cRepo = new ContractRepository(); AppointmentRepository rep = new AppointmentRepository(); int appointmentId = Convert.ToInt32(radGridView3.SelectedRows[0].Cells[0].Value.ToString()); Appointment appo = rep.getAppointment(appointmentId); string[] parts = appo.Description.Split('/'); foreach (string part in parts) { DefaultSetting ds = dRepo.GetSetting(part); value += Convert.ToInt32(ds.Value); } Contract contract = cRepo.getContract(appo.ContractId.Value); contract.ContractPayment -= value; cRepo.updateContract(contract); rep.deleteAppointment(appointmentId); ContractRepository repository = new ContractRepository(); radGridView1.DataSource = repository.getContractsByCustomerId(customerId).ToList(); } }
public ActionResult Index(IndexVM model) { model.Pager = model.Pager ?? new PagerVM(); model.Pager.Page = model.Pager.Page <= 0 ? 1 : model.Pager.Page; model.Pager.ItemsPerPage = model.Pager.ItemsPerPage <= 0 ? 10 : model.Pager.ItemsPerPage; model.Filter = model.Filter ?? new FilterVM(); model.Filter.PatientId = model.PatientId; model.Filter.DoctorId = model.DoctorId; model.Filter.AppointmentDate = model.AppointmentDate; Expression <Func <Appointment, bool> > filter = model.Filter.GenerateFilter(); AppointmentRepository repo = new AppointmentRepository(); model.items = repo.GetAll(filter, model.Pager.Page, model.Pager.ItemsPerPage); model.Pager.PagesCount = (int)Math.Ceiling(repo.Count(filter) / (double)(model.Pager.ItemsPerPage)); PatientRepository patientsRepo = new PatientRepository(); //model.PatientOne = patientsRepo.GetById(model.PatientId); model.PatientList = patientRepo.GetAll(); DoctorRepository doctorsRepo = new DoctorRepository(); //model.DoctorOne = doctorsRepo.GetById(model.DoctorId); model.DoctorList = doctorRepo.GetAll(); return(View(model)); }
public void GetAllAsync_Returns_AppointmentsList() { using (var dbContext = AppointmentDbContextInMemory.CreateInMemoryDbContext()) { //Arrange var appointment1 = new Appointment { Id = 5, Title = "test1" }; var appointment2 = new Appointment { Id = 6, Title = "test2" }; var appointment3 = new Appointment { Id = 7, Title = "test3" }; dbContext.Appointments.Add(appointment1); dbContext.Appointments.Add(appointment2); dbContext.Appointments.Add(appointment3); dbContext.SaveChanges(); //Act var sut = new AppointmentRepository(dbContext); var result = sut.GetAsync(It.IsAny <CancellationToken>()); //Assert Assert.NotNull(result); Assert.IsType <Task <List <Appointment> > >(result); } }
public async Task DeleteByIdAsync_Deletes_AppointmentAsync() { using (var dbContext = AppointmentDbContextInMemory.CreateInMemoryDbContext()) { //Arrange var appointment1 = new Appointment { Id = 9, Title = "test1" }; var appointment2 = new Appointment { Id = 10, Title = "test2" }; var appointment3 = new Appointment { Id = 11, Title = "test3" }; dbContext.Appointments.Add(appointment1); dbContext.Appointments.Add(appointment2); dbContext.Appointments.Add(appointment3); dbContext.SaveChanges(); //Act var sut = new AppointmentRepository(dbContext); await sut.DeleteByIdAsync(9, It.IsAny <CancellationToken>()); var result = sut.GetByIdAsync(9, It.IsAny <CancellationToken>()); //Assert Assert.Null(result.Result); } }
public async Task AddAsync_Adds_AppointmentAsync() { using (var dbContext = AppointmentDbContextInMemory.CreateInMemoryDbContext()) { //Arrange var appointment1 = new Appointment { Id = 12, Title = "test1" }; var appointment2 = new Appointment { Id = 13, Title = "test2" }; var appointment3 = new Appointment { Id = 14, Title = "test3" }; //Act var sut = new AppointmentRepository(dbContext); await sut.SaveAsync(appointment1, It.IsAny <CancellationToken>()); await sut.SaveAsync(appointment2, It.IsAny <CancellationToken>()); await sut.SaveAsync(appointment3, It.IsAny <CancellationToken>()); var result = sut.GetAsync(It.IsAny <CancellationToken>()); //Assert Assert.Equal(3, result.Result.Count); } }
public void Appointment_EditAppointment_DoesNot_ChangeUserAndWorkload() { string GUID = "068397FA-A41E-443F-823D-E2A6585BD322"; string WORKLOAD_GUID = "90cac674-18c0-4139-8aae-f9711bd2d5f4"; ArdaTestMgr.Validate(this, $"AppointmentRepository.EditAppointment({GUID})", (list, ctx) => { AppointmentRepository appointment = new AppointmentRepository(ctx); var row = new AppointmentViewModel() { _AppointmentComment = "Updated appointment", _AppointmentDate = DateTime.Parse("2111-11-11"), _AppointmentHoursDispensed = 100, _AppointmentID = Guid.Parse(GUID), _AppointmentTE = (decimal)123.45, _AppointmentUserUniqueName = "*****@*****.**", _AppointmentWorkloadWBID = Guid.Parse(WORKLOAD_GUID) }; appointment.EditAppointment(row); return(appointment.GetAppointmentByID(Guid.Parse(GUID))); }); }
public void Appointment_EditAppointment() { string GUID = "068397FA-A41E-443F-823D-E2A6585BD322"; string WORKLOAD_GUID = "c1507019-1d97-4629-8015-c01bf02ce6ab"; ArdaTestMgr.Validate(this, $"AppointmentRepository.EditAppointment({GUID})", (list, ctx) => { AppointmentRepository appointment = new AppointmentRepository(ctx); var row = new AppointmentViewModel() { _AppointmentComment = "Updated appointment", _AppointmentDate = DateTime.Parse("2111-11-11"), _AppointmentHoursDispensed = 100, _AppointmentID = Guid.Parse(GUID), _AppointmentTE = (decimal)123.45, _AppointmentUserUniqueName = "*****@*****.**", _AppointmentWorkloadWBID = Guid.Parse(WORKLOAD_GUID) }; appointment.EditAppointment(row); return(appointment.GetAppointmentByID(Guid.Parse(GUID))); }); }
public void Appointment_AddNewAppointment() { string GUID = "5348CCBE-7BED-4B5C-A2CE-E3E872F2CBC5"; string WORKLOAD_GUID = "c1507019-1d97-4629-8015-c01bf02ce6ab"; ArdaTestMgr.Validate(this, $"AppointmentRepository.AddNewAppointment({GUID})", (list, ctx) => { AppointmentRepository appointment = new AppointmentRepository(ctx); var row = new AppointmentViewModel() { _AppointmentComment = "My Appointment", _AppointmentDate = DateTime.Parse("2020-01-20"), _AppointmentHoursDispensed = 8, _AppointmentID = Guid.Parse(GUID), _AppointmentTE = (decimal)100.0, _AppointmentUserUniqueName = "*****@*****.**", _AppointmentWorkloadWBID = Guid.Parse(WORKLOAD_GUID) }; appointment.AddNewAppointment(row); return(appointment.GetAllAppointmentsSimple()); }); }
public DoctorService(DoctorRepository doctorRepository, UserRepository userRepository, AddressRepository addressRepository, ScheduleRepository scheduleRepository, AppointmentRepository appointmentRepository, WaitingRepository waitingRepository) { _doctorRepository = doctorRepository; _userRepository = userRepository; _addressRepository = addressRepository; _scheduleRepository = scheduleRepository; _appointmentRepository = appointmentRepository; _waitingRepository = waitingRepository; }
public PatientService(PatientRepository patientRepository, AppointmentRepository appointmentRepository, WaitingRepository waitingRepository) { _patientRepository = patientRepository; _appointmentRepository = appointmentRepository; _waitingRepository = waitingRepository; }