Пример #1
0
        public async Task <IActionResult> Create([Bind("ID,Username,Temperature,Status,Visit")] UserModel userModel)
        {
            if (ModelState.IsValid)
            {
                _context.Add(userModel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(ScreeningList)));
            }
            return(View(userModel));
        }
Пример #2
0
        public async Task <IActionResult> Create([Bind("ID,UserEmail,Type,Services,Charges,Appointment_Date,Appointment_Status")] AppointmentModel appointment)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    DateTime now = DateTime.Now;
                    appointment.User_Booked_Date = now;
                    _context.Add(appointment);
                    await _context.SaveChangesAsync();//save appointment and respective services record

                    //return RedirectToAction("UserAppointment");
                }
                catch (Exception e)
                {
                    ViewBag.msg = "Error: " + e.ToString();
                }

                try
                {
                    queueClient = new QueueClient(ServiceBusConnectionString, QueueName);
                    // Create a new message to send to the queue.
                    string messageBody = $"Message: {appointment.UserEmail} is requesting appointment on {appointment.Appointment_Date}.";
                    var    message     = new Message(Encoding.UTF8.GetBytes(messageBody));

                    // Write the body of the message to the console.
                    Console.WriteLine($"Sending message: {messageBody}");

                    // Send the message to the queue.
                    await queueClient.SendAsync(message);

                    ViewBag.msg = "success";
                }
                catch (Exception exception)
                {
                    ViewBag.msg = exception.ToString();
                }
            }
            return(View());
        }