public async Task <Response> Insert([FromForm] AppointmentServices model) { Response _objResponse = new Response(); try { if (ModelState.IsValid) { _context.Add(model); await _context.SaveChangesAsync(); _objResponse.Status = "Success"; _objResponse.Data = null; } else { _objResponse.Status = "Validation Error"; _objResponse.Data = null; } } catch (Exception ex) { _objResponse.Data = null; _objResponse.Status = ex.ToString(); Console.WriteLine("\nMessage ---\n{0}", ex.ToString()); Console.WriteLine("\nStackTrace ---\n{0}", ex.StackTrace); } return(_objResponse); }
public async Task <Response> Update(int id, [FromForm] AppointmentServices model) { Response _objResponse = new Response(); try { if (id != model.AppointmentId) { _objResponse.Status = "No record found"; _objResponse.Data = null; } else { _context.Entry(model).State = EntityState.Modified; await _context.SaveChangesAsync(); _objResponse.Status = "Success"; _objResponse.Data = null; } } catch (Exception ex) { _objResponse.Data = null; _objResponse.Status = ex.ToString(); Console.WriteLine("\nMessage ---\n{0}", ex.ToString()); Console.WriteLine("\nStackTrace ---\n{0}", ex.StackTrace); } return(_objResponse); }
public void TestGetById() { var AppointmentService = new AppointmentServices(_AppointmentRepository.Object); var result = AppointmentService.GetById(1); Assert.NotNull(result); }
public void TestGetAll() { var AppointmentService = new AppointmentServices(_AppointmentRepository.Object); var result = AppointmentService.GetAll(); Assert.True(result.Count() == 10); }
public async Task TestDeleteTask() { var AppointmentService = new AppointmentServices(_AppointmentRepository.Object); var result = await AppointmentService.Delete(5); Assert.True(result); }
public PatientsController(ApplicationDbContext context, IService <Patient> Patientservice , IHostingEnvironment hostingEnvironment, RecordsServices RecordeService , AppointmentServices appointmentsServices) { _context = context; patientservice = Patientservice; this.hostingEnvironment = hostingEnvironment; recordeService = RecordeService; this.appointmentsServices = appointmentsServices; }
public async Task TestUpdateTask() { var AppointmentService = new AppointmentServices(_AppointmentRepository.Object); var newAppointment = Builder <Appointment> .CreateNew() .With(q => q.id = 1) .Build(); var result = await AppointmentService.Update(newAppointment); Assert.AreEqual(newAppointment, result); }
public void DeclareAllObj() { try { objAppointmentservices = new AppointmentServices(); objMasterConsultantSerices = new MasterConsultantServices(); objDrScheduleServices = new DrScheduleServices(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
public void TestAddTaskShouldThrowException_Appointmentinthesamedayexists() { var AppointmentService = new AppointmentServices(_AppointmentRepository.Object); var currentDate = DateTime.Now; var newAppointment = Builder <Appointment> .CreateNew() .With(q => q.id = 0) .With(q => q.patientId = 1) .With(q => q.appointmentDate = currentDate.AddDays(1)) .Build(); ; Assert.ThrowsAsync <ValidationException>(async() => await AppointmentService.Add(newAppointment)); }
public async Task TestAddTask() { var AppointmentService = new AppointmentServices(_AppointmentRepository.Object); var currentDate = DateTime.Now; var newAppointment = Builder <Appointment> .CreateNew() .With(q => q.id = 0) .With(q => q.patientId = 1) .With(q => q.appointmentDate = currentDate.AddDays(25)) .Build(); var result = await AppointmentService.Add(newAppointment); Assert.True(result.id == 525); }
public async Task TestDeleteTaskShouldThrowException_cannotcancelappointmentoftoday() { var todayAppointment = Builder <Appointment> .CreateNew() .With(q => q.id = 25) .With(q => q.patientId = 1) .With(q => q.appointmentDate = DateTime.Now.AddMinutes(5)) .Build(); _AppointmentRepository.Setup(x => x.GetById(It.IsAny <int>())).Returns((int id) => todayAppointment); var AppointmentService = new AppointmentServices(_AppointmentRepository.Object); Assert.ThrowsAsync <ValidationException>(async() => await AppointmentService.Delete(25)); }
public AppointmentsController(AppointmentServices appointmentsManager) { this.appointmentsManager = appointmentsManager; }