예제 #1
0
        public async Task <IActionResult> Book(string partitionKey, string rowKey)
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(Redirect("Identity/Account/Login"));
            }
            try
            {
                var tbl = slots.CloudeTableStorage;

                var slot = tbl.Retrieve <Slot>(partitionKey, rowKey);
                slot.Id = 0;
                if (slot.IsBooked)
                {
                    return(RedirectToAction("Index"));
                }
                slot.IsBooked = true;

                _context.Add(GetAppointment(slot));
                Task <int> saving = _context.SaveChangesAsync();
                slots.Update(slot);

                await saving;
                sb.Send($"User: {User.Identity.Name} booked the slot: p[{slot.PartitionKey}] r[{slot.RowKey}] v[{slot.TimeStart}]");
                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine(ex.Message);
                return(RedirectToAction("Error", "Home"));
            }
        }
예제 #2
0
        public async Task <IActionResult> DeleteConfirmed(int id)
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(Redirect("Identity/Account/Login"));
            }
            if (!Doctor.IsDoctor(User))
            {
                return(NotFound());
            }

            var appointment = await _context.Appointment.FindAsync(id);

            _context.Appointment.Remove(appointment);
            await _context.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }