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);
        }
예제 #3
0
        public void TestGetById()
        {
            var AppointmentService = new AppointmentServices(_AppointmentRepository.Object);
            var result             = AppointmentService.GetById(1);

            Assert.NotNull(result);
        }
예제 #4
0
        public void TestGetAll()
        {
            var AppointmentService = new AppointmentServices(_AppointmentRepository.Object);
            var result             = AppointmentService.GetAll();

            Assert.True(result.Count() == 10);
        }
예제 #5
0
        public async Task TestDeleteTask()
        {
            var AppointmentService = new AppointmentServices(_AppointmentRepository.Object);
            var result             = await AppointmentService.Delete(5);

            Assert.True(result);
        }
예제 #6
0
 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;
 }
예제 #7
0
        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);
        }
예제 #8
0
 public void DeclareAllObj()
 {
     try
     {
         objAppointmentservices     = new AppointmentServices();
         objMasterConsultantSerices = new MasterConsultantServices();
         objDrScheduleServices      = new DrScheduleServices();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
예제 #9
0
        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));
        }
예제 #10
0
        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);
        }
예제 #11
0
        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));
        }
예제 #12
0
 public AppointmentsController(AppointmentServices appointmentsManager)
 {
     this.appointmentsManager = appointmentsManager;
 }