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")); }
public AppointmentFreeValidationResponseModel ValidateIsAppointmentTimeFree() { AppointmentFreeValidationResponseModel result = _appointmentsService.CheckIsAppointmentRequestTimeFree(AppointmentRequestDate, Duration); return(result); }