Example #1
0
        public async Task DeleteByIdCorectlyForOwnAppointment()
        {
            // Arrange
            var db = this.GetDatabase();
            var firstAppointment = new Appointment()
            {
                Id        = 1,
                CreatorId = "99",
                Title     = "Title"
            };

            db.Add(firstAppointment);

            await db.SaveChangesAsync();

            var appointmentService = new AppointmentService(db);

            // Act
            await appointmentService.DeleteById(1, "99");

            // Assert
            var deletedAppointment = db.Appointments.Find(1);

            deletedAppointment.IsDeleted.ShouldBeEquivalentTo(true);
        }
Example #2
0
 public ActionResult Delete(int id)
 {
     if (appointmentService.DeleteById(id))
     {
         TempData["Message"] = "Appointment deleted successfully!";
     }
     else
     {
         TempData["ErrorMessage"] = "Ooops something went wrong";
     }
     return(RedirectToAction("GetAll"));
 }
Example #3
0
        public async Task DeleteByIdCorectlyForRequestedAppointment()
        {
            // Arrange
            var db               = this.GetDatabase();
            var appointmentId    = 1;
            var firstAppointment = new Appointment()
            {
                Id        = appointmentId,
                CreatorId = "99",
                Title     = "Title"
            };
            var userScheduleId = 10;
            var userId         = "88";
            var user           = new User()
            {
                Id         = userId,
                ScheduleId = userScheduleId
            };

            db.Add(user);
            db.Add(firstAppointment);

            await db.SaveChangesAsync();

            var appointmentService = new AppointmentService(db);

            // Act
            var scheduleAppointment = new ScheduleAppointment()
            {
                ScheduleId    = userScheduleId,
                AppointmentId = appointmentId
            };

            db.ScheduleAppointments.Add(scheduleAppointment);

            await appointmentService.DeleteById(appointmentId, userId);

            // Assert
            var deletedAppointment = db.ScheduleAppointments.Find(userScheduleId, appointmentId);

            deletedAppointment.Should().BeNull();
        }