コード例 #1
0
        public ActionResult <ItemResponse <int> > Create(AppointmentAddRequest model)
        {
            ObjectResult result = null;

            try
            {
                int userId = _authService.GetCurrentUserId();

                int id = _service.Add(model, userId);
                ItemResponse <int> response = new ItemResponse <int>()
                {
                    Item = id
                };

                result = Created201(response);
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.ToString());
                ErrorResponse response = new ErrorResponse(ex.Message);

                result = StatusCode(500, response);
            }

            return(result);
        }
コード例 #2
0
        public IActionResult Add(AppointmentDto appointmentDto)
        {
            if (_appointmentService.Add(appointmentDto) == null)
            {
                return(NotFound());
            }

            return(Ok(appointmentDto));
        }
コード例 #3
0
        public async Task <IActionResult> Add([FromBody] AppointmentViewModel viewModel)
        {
            if (viewModel.From > viewModel.To)
            {
                throw new Exception(Constants.InvalidTimeLineExceptionMessage);
            }
            var id = await _service.Add(viewModel);

            return(Ok(new { id }));
        }
コード例 #4
0
        public async Task <IActionResult> PostAppointment(mp_appointment appointment)
        {
            //  var email = _userManager.GetUserId(HttpContext.User);
            //  var user = await _userManager.FindByEmailAsync(email);

            appointment.created_by = appointment.client_id.ToString();
            _appointmentService.Add(appointment);

            return(Ok(appointment.id));
        }
コード例 #5
0
        public IActionResult Add(Appointment appointment)
        {
            var result = _appointmentService.Add(appointment);

            if (result.Success)
            {
                return(Ok(result));
            }

            return(BadRequest(result));
        }
コード例 #6
0
        public async Task <IActionResult> Add([FromBody] AppointmentDTO appoimentDTO)
        {
            try
            {
                var response = await _appointmentService.Add(appoimentDTO);

                return(HandleSuccessResponse(response));
            }
            catch (Exception ex)
            {
                return(HandleErrorResponse(ex));
            }
        }
コード例 #7
0
 public JsonResult AddOrUpdateAppointment(Appointment model)
 {
     if (model.Id == 0)
     {
         model.CreatedName = DateTime.Now;
         appointmentsService.Add(model);
     }
     else
     {
         model.UpdatedDate = DateTime.Now;
         appointmentsService.Update(model);
     }
     return(Json("200"));
 }
コード例 #8
0
 private void tbtnSave_ItemClick(object sender, TileItemEventArgs e)
 {
     ExceptionHandler.HandleException(() => {
         var appointmentToAdd = new Appointment
         {
             EnvoyId           = Convert.ToInt32(cmbEnvoy.EditValue),
             AppointmentDate   = dtpAppoinmentDate.DateTime,
             AppointmentDetail = txtAppointmentDetail.Text,
             CustomerId        = frmMain.customerIdx
         };
         _appointmentService.Add(appointmentToAdd);
         tbtnSave.Enabled = false;
         XtraMessageBox.Show("Başarıyla oluşturuldu.");
     });
 }
コード例 #9
0
        public async Task <IActionResult> Create(Appointment viewModel)
        {
            if (User.IsInRole(Roles.Client) || !User.Identity.IsAuthenticated)
            {
                return(NotFound());
            }
            if (ModelState.IsValid)
            {
                var Id = await _appointmentService.Add(viewModel);

                if (!String.IsNullOrEmpty(Request.Form["continue"]))
                {
                    return(RedirectToAction("Edit", new { Id = Id }));
                }
                if (!String.IsNullOrEmpty(Request.Form["new"]))
                {
                    return(RedirectToAction(nameof(Create)));
                }
                return(RedirectToAction(nameof(Index)));
            }

            return(View(viewModel));
        }
コード例 #10
0
 public IActionResult AddEditAppointment([FromBody] Appointments model)
 {
     try
     {
         if (model.Id == 0)
         {
             var isBook = _appointment.GetSingle(x => x.pet_id == model.pet_id && x.appointmentDate.Date == model.appointmentDate.Date && x.appointmentSlot.Equals(model.appointmentSlot));
             if (isBook != null)
             {
                 return(_jsonResponse.GenerateJsonResult(0, "Appointment is already book"));
             }
             _appointment.Add(model);
             _appointment.Save();
             return(_jsonResponse.GenerateJsonResult(1, "Appointment save Successfully"));
         }
         else
         {
             var isBook = _appointment.GetSingle(x => x.Id != model.Id && x.pet_id == model.pet_id && x.appointmentDate.Date == model.appointmentDate.Date && x.appointmentSlot.Equals(model.appointmentSlot));
             if (isBook != null)
             {
                 return(_jsonResponse.GenerateJsonResult(0, "Appointment is already book"));
             }
             var edit = _appointment.GetSingle(x => x.Id == model.Id);
             edit.pet_id          = model.pet_id;
             edit.appointmentDate = model.appointmentDate;
             edit.appointmentSlot = model.appointmentSlot;
             _appointment.Update(edit);
             _appointment.Save();
             return(_jsonResponse.GenerateJsonResult(1, "Appointment update Successfully"));
         }
     }
     catch (Exception ex)
     {
         return(_jsonResponse.GenerateJsonResult(0, "UnhandledError"));
     }
 }
コード例 #11
0
        public ActionResult Create(mp_appointment appointment)
        {
            var service    = DAL.Utils.Options.GetAppointmentServices().FirstOrDefault(e => e.id == appointment.appointment_service);
            var collection = Request.Form;
            var date       = collection["date"] + " " + collection["time"];
            var start_date = DateTime.Parse(date);

            appointment.start_date = start_date;
            appointment.end_date   = start_date.AddMinutes(service.time_minutes);


            Guid       logged_user_id = Guid.Parse(_userManager.GetUserId(HttpContext.User));
            mp_profile user_profile   = _profileService.GetByUserId(logged_user_id);

            appointment.client_id = user_profile.id;
            Guid appointment_id;

            var clinician_available = _clinicianAvailabilityService.GetClinicianAvailabilityByDateRange(appointment);

            if (clinician_available != null)
            {
                //clinician is available by settings
                //now check if clinician already has appointment fixed
                var clinician_appointments = _appointmentService.GetClinicianAppointmentsByDateRange(appointment);
                if (clinician_appointments.Count() < 1)
                {
                    //clinician does not have appointments set for that time
                    //fix appointment
                    appointment_id             = _appointmentService.Add(appointment);
                    TempData["appointment_id"] = appointment_id;
                    TempData["AlertType"]      = "alert-success";
                    TempData["AlertMessage"]   = "We have found an available clinician for you. Please make payment to confirm your booking";
                    return(RedirectToAction(nameof(ConfirmAppointment)));
                }
                //else
                //{
                //    //clinician is already occupied
                //    alternative_clinician = GetAvailableClinician(appointment);
                //    if (alternative_clinician != null)
                //    {
                //        appointment.clinician_id = alternative_clinician.id;
                //        appointment_id = _appointmentService.Add(appointment);
                //        TempData["appointment_id"] = appointment_id;
                //        TempData["AlertType"] = "alert-success";
                //        TempData["AlertMessage"] = "We have found an available clinician for you. Please make payment to confirm your booking";
                //        return RedirectToAction(nameof(ConfirmAppointment));
                //    }
                //    //check for other available clinicians
                //}
            }
            //else
            //{
            //    alternative_clinician = GetAvailableClinician(appointment);
            //    if (alternative_clinician != null)
            //    {
            //        appointment.clinician_id = alternative_clinician.id;
            //        appointment_id = _appointmentService.Add(appointment);
            //        TempData["appointment_id"] = appointment_id;
            //        TempData["AlertType"] = "alert-success";
            //        TempData["AlertMessage"] = "We have found an available clinician for you. Please make payment to confirm your booking";
            //        return RedirectToAction(nameof(ConfirmAppointment));
            //    }
            //    //check for other available clinicians
            //}

            //if we got here, then no clinician was available
            TempData["AlertType"]    = "alert-warning";
            TempData["AlertMessage"] = "Sorry, we couldn't get an available clinician. Please change your dates and try again";
            return(RedirectToAction("Clinicians", "Clinician"));
        }
コード例 #12
0
        public JsonResult Post([FromBody] ContractRequest <AddUpdateAppointmentRequest> request)
        {
            var appointmentsResponse = _appointmentService.Add(request);

            return(Json(appointmentsResponse));
        }