Example #1
0
        public async Task DeleteAsync_ById_Ok()
        {
            //Arrange
            int id = 3;

            //Act
            var actual = await _albumService.DeleteAsync(id);

            //Assert
            actual.Should().BeTrue();
        }
Example #2
0
        public async Task <IActionResult> Delete(int id)
        {
            var albumEntity = await _albumService.GetByIdAsync(id);

            await _albumService.DeleteAsync(albumEntity);

            return(RedirectToAction(nameof(Index)));
        }
Example #3
0
        public async Task <IActionResult> DeteteAsync(ObjectId id)
        {
            var album = await _albumService.GetAsync(id);

            if (album == null)
            {
                return(NotFound());
            }
            await _albumService.DeleteAsync(id);

            return(NoContent());
        }
        public async Task <ActionResult <AlbumEntity> > DeleteAlbumEntity(int id)
        {
            if (id <= 0)
            {
                return(NotFound());
            }

            var albumEntity = await _albumService.GetByIdAsync(id);

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

            await _albumService.DeleteAsync(id);

            return(Ok(albumEntity));
        }
Example #5
0
        public async Task<ActionResult> Delete(int id, IFormCollection collection)
        {
            var model = await _albumService.GetByIdAsync(id);
            if (model == null)
            {
                return RedirectToAction(nameof(Index));
                // return NotFound();
            }

            try
            {
                await _albumService.DeleteAsync(model);
                return RedirectToAction(nameof(Index));
            }
            catch
            {
                return View();
            }
        }
        public async Task <ActionResult <bool> > Delete(int id)
        {
            try
            {
                var result = await _albumService.GetAsync(id);

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

                return(Ok(await _albumService.DeleteAsync(id)));
            }
            catch (Exception ex)
            {
                return(Conflict(ex.Message));

                throw;
            }
        }
Example #7
0
        public async Task <IActionResult> Delete(int id)
        {
            var album = await _albumService.GetByIdAsync(id);

            if (album == null)
            {
                return(RedirectToAction(nameof(Index)));
                // return NotFound();
            }

            try
            {
                await _albumService.DeleteAsync(album);

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View());
            }
        }
Example #8
0
        public async Task <IActionResult> OnPostDeleteAsync(params long[] id)
        {
            await _service.DeleteAsync(id);

            return(JsonData(true));
        }
Example #9
0
        public async Task <IActionResult> DeleteConfirmed(int id)
        {
            await _albumService.DeleteAsync(id);

            return(RedirectToAction(nameof(Index)));
        }