Exemplo n.º 1
0
        public async Task CanDelete()
        {
            using var context = new DataContext(ContextOptions);
            var user = await GetUser(context);

            var trainingRepo = new TrainingRepository(context);
            var training     = await CreateTraining(context, user);

            trainingRepo.Add(training);
            var saved = await trainingRepo.SaveAll();

            Assert.IsTrue(saved);

            var trainingsReturned = await trainingRepo.GetAllByUserId(user.Id);

            Assert.AreEqual(1, trainingsReturned.Count());

            trainingRepo.Delete(trainingsReturned.ElementAt(0));
            await trainingRepo.SaveAll();

            var trainingsReturnedAfterDelete = await trainingRepo.GetAllByUserId(user.Id);

            Assert.IsEmpty(trainingsReturnedAfterDelete);

            var trainingExercisesAfterDelete = await context.TrainingExercises.ToListAsync();

            Assert.IsEmpty(trainingExercisesAfterDelete);

            var trainingExerciseSetsAfterDelete = await context.TrainingExerciseSets.ToListAsync();

            Assert.IsEmpty(trainingExerciseSetsAfterDelete);
        }
Exemplo n.º 2
0
        public HttpResponseMessage Delete(int trainingId)
        {
            var repo     = new TrainingRepository();
            var dbResult = repo.Delete(trainingId);

            return(Request.CreateUpdateRecordResponse(dbResult));
        }
Exemplo n.º 3
0
 public IActionResult Delete(int id)
 {
     _repository.Delete(id);
     return(Ok());
 }
Exemplo n.º 4
0
 public void Delete(int id)
 {
     _repository.Delete(id);
 }