Beispiel #1
0
        public void Delete_should_throw_ItemNotFoundException_if_genre_with_specified_id_does_not_exist_in_the_database()
        {
            //Arrange
            _genreRepository.Setup(x => x.Get(It.IsAny <int>())).Returns <Genre>(null);

            //Act & Assert
            Assert.Throws <ItemNotFoundException>(() => _genreService.Delete(It.IsAny <int>()));
        }
Beispiel #2
0
        public override void DeleteByExistingId()
        {
            MockGenreRepository.Setup(r => r.GetById(MockGenreBO.Id)).Returns(MockGenre);
            MockGenreRepository.Setup(r => r.Delete(MockGenreBO.Id)).Returns(true);

            var delete = _service.Delete(MockGenre.Id);

            Assert.True(delete);
        }
Beispiel #3
0
        public ActionResult DeleteConfirmed(int id)
        {
            Genre genre = _genreService.Find(id);

            _genreService.Delete(genre);
            return(RedirectToAction("Manage"));
        }
Beispiel #4
0
        public IActionResult RemoveGenre(int id)
        {
            var result = genreService.GetById(id);

            genreService.Delete(result);
            return(RedirectToAction("Index"));
        }
Beispiel #5
0
        public ActionResult DeleteConfirmed(Guid id)
        {
            Genre genre = _service.GetGenreById(id);

            _service.Delete(genre.Id);
            return(RedirectToAction("Index"));
        }
Beispiel #6
0
        public IActionResult DeleteComfirmed(int id)
        {
            var genre = _genreService.GetGenreById(id);

            _genreService.Delete(genre.Id);
            return(RedirectToAction(nameof(Index)));
        }
 public IActionResult DeleteGenre(long id)
 {
     _logger.LogInformation($"{nameof(GenreController)} : {nameof(DeleteGenre)} was called.");
     try
     {
         var genre = _genreService.FindById(id);
         if (genre == null)
         {
             return(StatusCode((int)HttpStatusCode.Gone));
         }
         _genreService.Delete(genre);
         _genreService.Save();
         return(Ok());
     }
     catch (DbException exception)
     {
         _logger.LogError(exception.Message);
         return(BadRequest(exception.Message));
     }
     catch (Exception exception)
     {
         _logger.LogError(exception.Message);
         throw;
     }
 }
Beispiel #8
0
 public ActionResult DeleteConfirmed(int id)
 {
     //Genre genre = db.Genres.Find(id);
     //db.Genres.Remove(genre);
     //db.SaveChanges();
     _genreService.Delete(id);
     return(RedirectToAction("Index"));
 }
        public ActionResult DeleteConfirmed(int id, int northWindId)
        {
            Genre genre = _genreService.Get(id, northWindId);

            _genreService.Delete(genre);

            return(RedirectToAction("Index"));
        }
Beispiel #10
0
 public ActionResult DeleteGenre(int?id)
 {
     if (id != null)
     {
         genreService.Delete(Convert.ToInt32(id));
     }
     return(RedirectToAction("AllGenres", "Libraryan"));
 }
Beispiel #11
0
        public async Task <ActionResult> Delete(int id)
        {
            var result = await _genreService.Delete(id);

            if (result)
            {
                return(Ok());
            }
            return(BadRequest());
        }
        public ActionResult <GenreViewModel> Delete(int id)
        {
            var result = _genreService.Delete(id);

            if (result == null)
            {
                return(NotFound());
            }
            return(result);
        }
        public IActionResult Delete(int id)
        {
            if (!UserIsInRole(UserTypeEnum.Admin))
            {
                return(Unauthorized("You are not in role to permit this action"));
            }

            _service.Delete(id);
            return(Ok());
        }
        public ValidationResult Remove(Genre genre)
        {
            BeginTransaction();
            ValidationResult.Add(_service.Delete(genre));
            if (ValidationResult.IsValid)
            {
                Commit();
            }

            return(ValidationResult);
        }
 public Genre Delete(int id)
 {
     try
     {
         return(_service.Delete(id));
     }
     catch (Exception)
     {
         throw new Exception("Unable to remove genre");
     }
 }
Beispiel #16
0
        public async Task <IActionResult> OnPostAsync()
        {
            int deletedGenre = await _genreService.Delete(genreOutputDto.Id);

            if (deletedGenre == 0)
            {
                return(NotFound());
            }

            return(RedirectToPage("Index"));
        }
Beispiel #17
0
        public IActionResult Delete(GenreDeleteViewModel viewModel)
        {
            Genre genre = genreService.GetByID(viewModel.Genre.ID);

            if (genre == null)
            {
                return(NotFound());
            }

            genreService.Delete(genre.ID);
            return(RedirectToAction("Index"));
        }
Beispiel #18
0
        public async Task <IActionResult> Delete(int id)
        {
            try {
                await _genreService.Delete(id);

                return(NoContent());
            } catch (EntityNotFoundException e) {
                return(NotFound(e.Message));
            } catch (Exception) {
                return(StatusCode(500, new { ServerErrorResponse.Message }));
            }
        }
 public IActionResult Delete([FromRoute] int id)
 {
     try
     {
         _genreService.Delete(id);
         return(Ok());;
     }
     catch
     {
         return(BadRequest());
     }
 }
Beispiel #20
0
        public async Task <IActionResult> Delete(int id)
        {
            try
            {
                await _genreService.Delete(id);

                return(NoContent());
            }
            catch (GenreNotFound)
            {
                return(NotFound());
            }
        }
Beispiel #21
0
        public void DeleteTest()
        {
            var id = genreService.Create(testName);

            try
            {
                var entity = genreService.Find(id);
                Assert.IsNotNull(entity);

                var success       = genreService.Delete(entity);
                var entityDeleted = genreService.Find(id);

                Assert.IsNull(entityDeleted);
                Assert.IsTrue(success);
            }
            catch (Exception)
            {
                var dbEntity = cdDb.Genres.SingleOrDefault(x => x.Id == id);
                cdDb.Genres.Remove(dbEntity);
                cdDb.SaveChanges();
            }
        }
Beispiel #22
0
        public IActionResult DeleteConfirmed(int Id)
        {
            if (ModelState.IsValid)
            {
                _genreService.Delete(Id);
            }
            else
            {
                _logger.LogInformation(LoggerMessageDisplay.GenreDeleteErrorModelStateInvalid);
            }

            return(RedirectToAction(nameof(Index)));
        }
        public ActionResult Delete(int id)
        {
            var genre = genreService.Find(id);

            if (!genreService.IsUse(genre))
            {
                genreService.Delete(genre);
                return(RedirectToAction("Index"));
            }
            else
            {
                return(View());
            }
        }
Beispiel #24
0
 public ActionResult Delete(int Id)
 {
     try
     {
         var genre = genreService.Find(Id);
         genreService.Delete(genre);
         InternalNotification.Success("Genre Deleted");
     }
     catch (Exception ex)
     {
         InternalNotification.Error(ex);
     }
     return(RedirectToAction("index"));
 }
        public ActionResult Delete(int id)
        {
            try
            {
                _genreService.Delete(id);
                ViewBag.SuccessMessage = "Item has been deleted";
            }
            catch (Exception e)
            {
                ViewBag.ErrorMessage = e.Message;
            }

            var genres = _genreService.GetAll().OrderBy(f => f.Name);

            return(View("Index", genres));
        }
        public IActionResult Delete(int id)
        {
            try
            {
                _genreService.Delete(id);
            }
            catch (ValidationException ex)
            {
                _loggerService.LogInformation(CONTROLLER_NAME + LoggerConstants.ACTION_DELETE + $"/{id}", LoggerConstants.TYPE_POST, $"delete genre id: {id} error: {ex.Message}", GetCurrentUserId());

                return(RedirectToAction("Error", "Home", new { requestId = "400", errorInfo = ex.Message }));
            }

            _loggerService.LogInformation(CONTROLLER_NAME + LoggerConstants.ACTION_DELETE + $"/{id}", LoggerConstants.TYPE_POST, $"delete genre id: {id} successful", GetCurrentUserId());

            return(RedirectToAction("Index"));
        }
Beispiel #27
0
        public ActionResult DeleteConfirmed(string id)
        {
            try
            {
                _service.Delete(id);

                return(RedirectToAction(nameof(Index)));
            }
            catch (Exception e)
            {
                return(View("Error", new ErrorViewModel
                {
                    RequestId = Request.HttpContext.TraceIdentifier,
                    Exception = e
                }));
            }
        }
Beispiel #28
0
        public async Task <IHttpActionResult> DeleteAsync(string genreName)
        {
            await Task.Yield();

            if (genreName == "")
            {
                return(BadRequest("Director name can not be empty"));
            }
            try
            {
                genreService.Delete(genreName);
                return(Content(HttpStatusCode.Created, $"{genreName} deleted"));
            }
            catch (DataBaseException)
            {
                return(Content(HttpStatusCode.NotFound, $"{genreName} does not exist in our servers"));
            }
            catch (AsociatedClassException)
            {
                return(Content(HttpStatusCode.Accepted, $"{genreName} has asociated movies"));
            }
        }
Beispiel #29
0
 public ResultResponse Delete(int id)
 {
     return(_service.Delete(id));
 }
Beispiel #30
0
        public HttpResponseMessage Delete([FromUri] int id)
        {
            _genreService.Delete(id);

            return(Request.CreateResponse(HttpStatusCode.OK));
        }