Ejemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("AppSessionId,AppId,SessionNo,Status,StartDateTime,EndDateTime")] AppointmentSession appointmentSession)
        {
            if (id != appointmentSession.AppSessionId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(appointmentSession);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AppointmentSessionExists(appointmentSession.AppSessionId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AppId"] = new SelectList(_context.Appointments, "AppId", "AppId", appointmentSession.AppId);
            return(View(appointmentSession));
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AppointmentSessionDetails"/> class
 /// </summary>
 public AppointmentSessionDetails(AppointmentSession session)
 {
     if (session == null)
     {
         throw new ArgumentNullException(nameof(session));
     }
 }
        /// <summary>
        /// Generates the Appointment Session and Appointment Slots per the config specification
        /// </summary>
        /// <param name="config"></param>
        /// <returns></returns>
        private AppointmentSession GenerateNewAppointmentSession(AppointmentSessionConfiguration config)
        {
            var slotDuration        = config.DurationInMins / config.NumberOfAppointmentSlots;
            var slots               = new List <AppointmentSlot>();
            var appointmentDateTime = config.StartDateTime;

            for (var i = 0; i < config.NumberOfAppointmentSlots; i++)
            {
                slots.Add(new AppointmentSlot()
                {
                    State = SlotState.Available,
                    AppointmentDateTime       = appointmentDateTime,
                    AppointmentDurationInMins = slotDuration,
                });

                //Advance the start time of the next appointment
                appointmentDateTime = appointmentDateTime.AddMinutes(slotDuration);
            }

            var session = new AppointmentSession()
            {
                DurationInMins        = config.DurationInMins,
                StartDateTime         = config.StartDateTime,
                MedicalPractitionerId = config.MedicalPractitionerId,
                AppointmentSlots      = slots
            };

            return(session);
        }
        public IActionResult Put(AppointmentSession appointmentsession)
        {
            var currentUser = GetCurrentUserProfile();

            appointmentsession.UserProfileId = currentUser.Id;
            _appointmentSessionRepo.Update(appointmentsession);
            return(NoContent());
        }
        public IActionResult AppointmentSession(AppointmentSession appointmentsession)
        {
            var currentUser = GetCurrentUserProfile();

            appointmentsession.UserProfileId = currentUser.Id;
            _appointmentSessionRepo.Add(appointmentsession);

            return(CreatedAtAction("Get", new { id = appointmentsession.Id }, appointmentsession));
        }
        /// <summary>
        /// Deletes the selected AppointmentSession
        /// </summary>
        /// <param name="session"></param>
        /// <returns></returns>
        public async Task <AppointmentBookResults> DeleteAppointmentSessionAsync(AppointmentSession session)
        {
            if (session == null)
            {
                throw new ArgumentNullException(nameof(session));
            }

            if (session.AppointmentSlots == null)
            {
                return(new AppointmentBookResults()
                {
                    ResultCode = ServiceResultStatusCode.Failed
                });
            }

            // Delete each of the slots that are associated with the session
            var slotDeleteSuccess = true;

            foreach (var slot in session.AppointmentSlots)
            {
                if (!await _apptSlotDal.DeleteAsync(slot))
                {
                    slotDeleteSuccess = false;
                }
            }

            // If the deletion of the Session's slots failed, return
            if (!slotDeleteSuccess)
            {
                return(new AppointmentBookResults()
                {
                    ResultCode = ServiceResultStatusCode.Failed
                });
            }

            // Delete the Session itself
            if (await _apptSessionDal.DeleteAsync(session.Id))
            {
                // If deletion is successful, return success result
                return(new AppointmentBookResults()
                {
                    ResultCode = ServiceResultStatusCode.Success
                });
            }

            return(new AppointmentBookResults()
            {
                ResultCode = ServiceResultStatusCode.Failed
            });
        }
Ejemplo n.º 7
0
        public async Task <IActionResult> Create([Bind("AppSessionId,AppId,SessionNo,Status,StartDateTime,EndDateTime")] AppointmentSession appointmentSession)
        {
            ViewBag.ShowLogOut = true;

            if (ModelState.IsValid)
            {
                _context.Add(appointmentSession);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AppId"]  = new SelectList(_context.Appointments, "AppId", "AppId", appointmentSession.AppId);
            ViewBag.ShowLogOut = true;
            return(View(appointmentSession));
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AppointmentSessionDetails"/> class
        /// </summary>
        public AppointmentSessionDetails(AppointmentSession session, User medicalPractitioner)
        {
            if (session == null)
            {
                throw new ArgumentNullException(nameof(session));
            }

            if (medicalPractitioner == null)
            {
                throw new ArgumentNullException(nameof(medicalPractitioner));
            }

            Id = session.Id;
            MedicalPractitioner = new MedicalPractitionerDetails(medicalPractitioner.Id, medicalPractitioner.JobDescription.Description, medicalPractitioner.EmployeeDetails);
            StartDateTime       = session.StartDateTime;
            EndDateTime         = session.StartDateTime.AddMinutes(session.DurationInMins);
            AppointmentSlots    = session.AppointmentSlots.ToList();
        }
Ejemplo n.º 9
0
 public void Update(AppointmentSession appointmentsession)
 {
     _context.Entry(appointmentsession).State = EntityState.Modified;
     _context.SaveChanges();
 }
Ejemplo n.º 10
0
 public void Add(AppointmentSession appointmentsession)
 {
     _context.Add(appointmentsession);
     _context.SaveChanges();
 }