Esempio n. 1
0
        public ActionResult New(AppointmentRequestModel request)
        {
            try
            {
                request.AppointmentHours = new List <SelectListItem>();
                if (ModelState.IsValid)
                {
                    Appointment appointment = new Appointment
                    {
                        DoctorId          = request.DoctorId,
                        AppointmentDate   = request.Date,
                        Details           = request.Details,
                        AppointmentHour   = request.ChosenAppointmentHour,
                        ApplicationUserId = this.User.Identity.GetUserId()
                    };

                    DbCtx.Appointments.Add(appointment);

                    DbCtx.SaveChanges();
                    return(RedirectToAction("Index", "Clinic"));
                }
                return(View(request));
            }
            catch (Exception e)
            {
                return(View(request));
            }
        }
Esempio n. 2
0
        public ActionResult Edit(int?id)
        {
            if (id.HasValue)
            {
                Appointment appointment = DbCtx.Appointments.Find(id);

                if (appointment == null)
                {
                    return(HttpNotFound("Couldn't find the appointment with id = " + id.ToString() + "!"));
                }

                if (appointment.ApplicationUserId != this.User.Identity.GetUserId() && !User.IsInRole("Admin"))
                {
                    return(RedirectToAction("Index", "Appointment"));
                }

                AppointmentRequestModel request = new AppointmentRequestModel
                {
                    AppointmentId         = (int)id,
                    DoctorId              = appointment.DoctorId,
                    ClinicName            = appointment.Doctor.Clinic.Name,
                    City                  = appointment.Doctor.Clinic.Address.City,
                    DoctorLastName        = appointment.Doctor.LastName,
                    DoctorFirstName       = appointment.Doctor.FirstName,
                    Date                  = appointment.AppointmentDate,
                    Details               = appointment.Details,
                    ChosenAppointmentHour = appointment.AppointmentHour,
                    //  AppointmentHours = GetAllAvailableHoursForEdit(appointment.AppointmentDate, appointment.DoctorId
                    AppointmentHours = new List <SelectListItem>()
                };

                return(View(request));
            }
            return(HttpNotFound("Missing appointment id parameter!"));
        }
Esempio n. 3
0
        public ActionResult New(int?id)
        {
            if (id.HasValue)
            {
                Doctor doctor = DbCtx.Doctors.Find(id);

                if (doctor == null)
                {
                    return(HttpNotFound("There is no doctor with this id!"));
                }

                AppointmentRequestModel appointmentRequestModel = new AppointmentRequestModel
                {
                    DoctorId = (int)id,
                    Date     = DateTime.Now,
                    ChosenAppointmentHour = "00:00",
                    AppointmentHours      = new List <SelectListItem>(),
                    DoctorFirstName       = doctor.FirstName,
                    DoctorLastName        = doctor.LastName,
                    City       = doctor.Clinic.Address.City,
                    ClinicName = doctor.Clinic.Name
                };

                return(View(appointmentRequestModel));
            }
            return(HttpNotFound("Missing doctor id parameter!"));
        }
Esempio n. 4
0
        public ActionResult Edit(int id, AppointmentRequestModel request)
        {
            try
            {
                request.AppointmentHours = new List <SelectListItem>();
                if (ModelState.IsValid)
                {
                    Appointment appointment = DbCtx.Appointments.Find(id);

                    if (TryValidateModel(appointment))
                    {
                        appointment.AppointmentDate = request.Date;
                        appointment.AppointmentHour = request.ChosenAppointmentHour;
                        appointment.Details         = request.Details;

                        DbCtx.SaveChanges();
                    }
                    return(RedirectToAction("Index", "Appointment"));
                }
                return(View(request));
            }
            catch (Exception e)
            {
                return(View(request));
            }
        }
 public AppointmentPage()
 {
     InitializeComponent();
     NavigationPage.SetHasNavigationBar(this, false);
     _apiServices = new RestApi();
     _baseUrl     = Settings.Url + Domain.AppointmentApiConstant;
     _objAppointmentResponseModel = new AppointmentResponseModel();
     _objAppointmentRequestModel  = new AppointmentRequestModel();
     _objHeaderModel = new HeaderModel();
     LoadUpcomingAppointment(1, string.Empty);
 }
Esempio n. 6
0
 public HomePage()
 {
     InitializeComponent();
     NavigationPage.SetHasNavigationBar(this, false);
     _apiServices                  = new RestApi();
     _baseUrl                      = Settings.Url + Domain.AppointmentApiConstant;
     _baseUrlPrescription          = Settings.Url + Domain.PrescriptionApiConstant;
     _baseUrlReports               = Settings.Url + Domain.ReportApiConstant;
     _objAppointmentResponseModel  = new AppointmentResponseModel();
     _objAppointmentRequestModel   = new AppointmentRequestModel();
     _objPrescriptionRequestModel  = new PrescriptionRequestModel();
     _objPrescriptionResponseModel = new PrescriptionResponseModel();
     _objReportRequestModel        = new ReportRequestModel();
     _objReportResponseModel       = new ReportResponseModel();
     _objHeaderModel               = new HeaderModel();
     //App.DetailPage = this;
     _objHeaderModel.OTPToken = Settings.TokenCode;
 }
        public async Task <OperationDataResult <AppointmentsListModel> > Index(AppointmentRequestModel requestModel)
        {
            try
            {
                var list = await _dbContext.Appointments
                           .Where(x => x.WorkflowState != Constants.WorkflowStates.Removed &&
                                  requestModel.EndDate > x.StartAt &&
                                  (requestModel.StartDate < x.StartAt ||
                                   x.RepeatType != null &&
                                   x.NextId == null &&
                                   (x.RepeatUntil == null || x.RepeatUntil > requestModel.StartDate)))
                           .Select(x => new AppointmentSimpleModel()
                {
                    Id          = x.Id,
                    StartAt     = x.StartAt,
                    ExpireAt    = x.ExpireAt,
                    Title       = x.Title,
                    ColorHex    = x.ColorHex,
                    RepeatUntil = x.RepeatUntil,
                    RepeatEvery = x.RepeatEvery,
                    RepeatType  = x.RepeatType,
                    NextId      = x.NextId
                }
                                   ).ToListAsync();

                var listModel = new AppointmentsListModel {
                    Total = list.Count(), Appointments = list
                };

                return(new OperationDataResult <AppointmentsListModel>(true, listModel));
            }
            catch (Exception e)
            {
                Trace.TraceError(e.Message);
                return(new OperationDataResult <AppointmentsListModel>(false,
                                                                       _appointmentLocalizationService.GetString("ErrorGettingAppointmentsList")));
            }
        }
Esempio n. 8
0
 public async Task <OperationDataResult <AppointmentsListModel> > Index(AppointmentRequestModel requestModel)
 {
     return(await _appointmentsService.Index(requestModel));
 }
Esempio n. 9
0
 public List <AppointmentResponseModel> AppointmentSearch([FromUri(Name = "")] AppointmentRequestModel request)
 {
     return(_repo.GetAvailableAppointmentsSlots(request));
 }
Esempio n. 10
0
        public async Task <AppointmentResponseModel> LoadAppointmentListAsync(string uri, Boolean IsHeaderRequired, HeaderModel objHeaderModel, AppointmentRequestModel _objAppointmentRequestModel)
        {
            AppointmentResponseModel objAppointmentResponseModel;
            string s = JsonConvert.SerializeObject(_objAppointmentRequestModel);
            HttpResponseMessage response = null;

            using (var stringContent = new StringContent(s, System.Text.Encoding.UTF8, "application/json"))
            {
                if (IsHeaderRequired)
                {
                    client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", objHeaderModel.OTPToken);
                }
                response = await client.PostAsync(uri, stringContent);


                if (response.IsSuccessStatusCode)
                {
                    var SucessResponse = await response.Content.ReadAsStringAsync();

                    objAppointmentResponseModel = JsonConvert.DeserializeObject <AppointmentResponseModel>(SucessResponse);
                    return(objAppointmentResponseModel);
                }
                else
                {
                    var ErrorResponse = await response.Content.ReadAsStringAsync();

                    objAppointmentResponseModel = JsonConvert.DeserializeObject <AppointmentResponseModel>(ErrorResponse);
                    return(objAppointmentResponseModel);
                }
            }
        }