Exemplo n.º 1
0
        public IActionResult OnPost()
        {
            if (!IsDateBeforeNow())
            {
                Message = new PageMessage
                {
                    Type = PageMessageType.Danger,
                    Text = "Датата не може да бъде в миналото."
                };
                return(Page());
            }

            AppointmentFreeValidationResponseModel responseModel = ValidateIsAppointmentTimeFree();

            if (!responseModel.IsRequestTimeFree)
            {
                Message = new PageMessage
                {
                    Type = PageMessageType.Danger,
                    Text = "Тази дата не е свободна."
                };
                return(Page());
            }
            var currentUserId = HttpContext.User.Claims
                                .FirstOrDefault(cl => cl.Type.Equals("sub"))
                                ?.Value;

            _appointmentsService.CreateAppointmentRequest(new AppointmentCreateInputModel
            {
                CustomerId = currentUserId,
                Date       = AppointmentRequestDate,
                OfferId    = OfferId
            });

            return(RedirectToPage("/Offers/Index"));
        }
Exemplo n.º 2
0
        public AppointmentFreeValidationResponseModel ValidateIsAppointmentTimeFree()
        {
            AppointmentFreeValidationResponseModel result = _appointmentsService.CheckIsAppointmentRequestTimeFree(AppointmentRequestDate, Duration);

            return(result);
        }