public async Task <IActionResult> Delete(int id)
 {
     if (await _placeService.Delete(id))
     {
         return(Ok());
     }
     _logger.LogError($"Could not delete place with id {id}");
     return(BadRequest("Failed to delete place"));
 }
Exemple #2
0
        public void TestDeletePlace(int?id)
        {
            switch (id)
            {
            case null:
                Assert.Throws <ArgumentNullException>(() =>
                                                      service.Delete(null));
                break;

            case 1:
                var place  = service.SelectById(1);
                var result = service.Delete(place);
                Assert.That(result.Equals("Successful!"));
                Assert.Throws <Exception>(() =>
                                          service.SelectById(1), "PlaceId can't be null!");

                break;

            default: break;
            }
        }
Exemple #3
0
        public ActionResult DeletePlace(int id)
        {
            // Get Tree list place
            List <int> lst = new List <int>();

            placeService.TreeListId(id, ref lst);
            if (lst != null)
            {
                placeService.Delete(lst);
            }
            ModelState.Clear();
            return(Redirect(Request.UrlReferrer.ToString()));
        }
Exemple #4
0
        public void PlaceServiceDelete_PlaceId_ReturnsExceptionNotFound()
        {
            // Arrange
            int placeId = 100;

            var uowMock = new Mock <IUnitOfWork>();

            uowMock.Setup(u => u.Places.Add(new Place {
                Id = 1, Name = "Kharkiv railway station"
            }));
            //uowMock.Setup(u => u.Places.Get(placeId)).Returns(new Place { Name = "Kharkiv railway station" });

            var placeService = new PlaceService(uowMock.Object);


            // Act
            Action deletingPlace = () => placeService.Delete(placeId);

            // Assert
            Assert.ThrowsException <Exception>(deletingPlace);
        }