public JsonResult ValidateAndComputeAppointmentSum(int restaurantId, int tableId, string agendaEvent) { try { var appointment = CreateAppointmentFromEvent(restaurantId, tableId, agendaEvent); if (!AppointmentsHelper.CheckForOverlappingAppointments(appointment, _context)) { double totalSumToPay = AppointmentsHelper.ComputeAppointmentAmount(appointment, _context); if (totalSumToPay == -1) { return(Json(new { success = false, respose = "You are banned to create appointments due not honoring them. Please contact restaurant management." })); } return(Json(new { success = true, responseText = totalSumToPay })); } else { return(Json(new { success = false, responseText = "Overlapping appointments. Please select another time-slot." })); } } catch (Exception ex) { return(Json(new { success = false, responseText = ex })); } }
public JsonResult SaveAppointment(int restaurantId, int tableId, string agendaEvent) { try { var appointment = CreateAppointmentFromEvent(restaurantId, tableId, agendaEvent); if (!AppointmentsHelper.CheckForOverlappingAppointments(appointment, _context)) { _context.Appointments.Add(appointment); _context.SaveChanges(); //TwilloCommunication.SendMessageToClient(""); if (!string.IsNullOrEmpty(appointment.persEmail)) { SmtpHelper.SendEmail(appointment, _context); } return(Json(new { success = true, responseText = appointment.Id })); } else { return(Json(new { success = false, responseText = "overlapping" })); } } catch (Exception ex) { return(Json(new { success = false, responseText = ex })); } }
public InitDataService(IOptions <AppSettings> settings, IMapper mapper) { appSettings = settings.Value; appointmentsHelper = new AppointmentsHelper(settings, mapper); }