Exemple #1
0
        public async Task <IActionResult> Delete(int ratingId)
        {
            try
            {
                var oldRating = await _repository.GetRatingByIdAsync(ratingId);

                if (oldRating == null)
                {
                    return(NotFound($"Could not find rating with with id of {ratingId}"));
                }

                _repository.Delete(oldRating);

                if (await _repository.SaveChangesAsync())
                {
                    return(Ok());
                }
            }
            catch (Exception ex)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, ex.Message));
            }

            return(BadRequest());
        }
Exemple #2
0
 public void DeleteRating(int ratingId)
 {
     //unitOfWork.StartTransaction();
     RatingRepository repo = new RatingRepository(unitOfWork);
     repo.Delete(x => x.RatingId == ratingId);
     //unitOfWork.Commit();
 }
Exemple #3
0
        public void DeleteById_WasDeleted_ActualDataIsNull()
        {
            var    typeIdToDelete = AddandGetTestRating().ID;
            Rating actualRating;

            using (var ratingRepo = new RatingRepository(new brothershipEntities(ConnectionStrings.TEST_CONNECTION_STRING_NAME)))
            {
                ratingRepo.Delete(typeIdToDelete);
                ratingRepo.SaveChanges();
                actualRating = ratingRepo.GetById(typeIdToDelete);
            }

            Assert.IsNull(actualRating);
        }
        public void AddandDeleteTest()
        {
            List <Rating> expected = Ratings();
            Rating        Rating   = new Rating()
            {
                Id = 13, CustomerService = 8, Quality = 6, OverAll = 8, Price = 8
            };

            expected.Add(Rating);
            repo.Add(Rating);
            List <Rating> actual  = repo.ReadAll();
            Rating        actuall = actual.Last();

            Assert.IsTrue(comparer(Rating, actuall));

            repo.Delete(Rating.Id);
            expected.Remove(Rating);

            Assert.IsTrue(listcomparer(repo.ReadAll(), expected));
        }
 public void Delete(int id)
 {
     _ratingRepository.Delete(id);
 }