コード例 #1
0
        public async Task <ActionResult> DeleteFilm(string filmName)
        {
            try
            {
                var film = await _repository.GetFilmByTitleAsync(filmName);

                if (film == null)
                {
                    return(BadRequest("Film doesn't exist"));
                }

                _repository.Delete(film);

                if (await _repository.SaveChangesAsync())
                {
                    return(Ok($"Film {filmName} was deleted"));
                }

                return(StatusCode(StatusCodes.Status500InternalServerError, "It looks like no changes were made"));
            }
            catch (Exception)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, "Database failure"));
            }
        }
コード例 #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            var model = _filmRepository.Get(id);

            _filmRepository.Delete(model);
            return(RedirectToAction("Index"));
        }
        public void CollectionFilmRepository_IT()
        {
            //Arrange
            var             kernel     = new StandardKernel(new DependencyInjection());
            ISerializer     serializer = kernel.Get <ISerializer>();
            IFilmRepository sut        = kernel.Get <IFilmRepository>(new ConstructorArgument("serializer", serializer));

            Film film1 = new Film("Aliens", new DateTime(1984, 1, 20), 5, Genre.Science_Fiction);
            Film film2 = new Film("Predator", new DateTime(1984, 1, 20), 5, Genre.Science_Fiction);

            //Act
            long id1 = sut.Insert(film1);
            long id2 = sut.Insert(film2);

            //Assert
            Assert.AreEqual(2, sut.SelectAll().Count, "Assertion 1");
            Assert.AreEqual(1, sut.SearchByTitle("Aliens").Count, "Assertion 2");
            Assert.AreEqual(film1, sut.SelectById(id1), "Assertion 3");
            Assert.AreEqual(film2, sut.SelectById(id2), "Assertion 4");

            film1.Stock = 0;
            sut.Update(film1);
            Assert.AreEqual(0, sut.SelectById(id1).Stock, "Assertion 5");

            sut.Delete(film2);
            Assert.IsNull(sut.SelectById(id2), "Assertion 6");
        }
コード例 #4
0
        private void Delete(object obj)
        {
            if (Model.Id != Guid.Empty)
            {
                var delete = _messageDialogService.Show(
                    $"Delete",
                    $"Do you want to delete {Model?.OriginalName}?",
                    MessageDialogButtonConfiguration.YesNo,
                    MessageDialogResult.No);
                if (delete == MessageDialogResult.No)
                {
                    return;
                }

                try
                {
                    _filmRepository.Delete(Model.Id);
                }
                catch
                {
                    var _ = _messageDialogService.Show(
                        $"Deleting of {Model?.OriginalName} failed!",
                        "Deleting failed",
                        MessageDialogButtonConfiguration.OK,
                        MessageDialogResult.OK);
                    return;
                }

                _mediator.Send(new DeleteMessage <FilmWrapper> {
                    Model = Model
                });
            }
        }
コード例 #5
0
        public async Task <ActionResult> Delete(string firstName, string lastName)
        {
            try
            {
                if (string.IsNullOrEmpty(firstName) || string.IsNullOrEmpty(lastName))
                {
                    return(BadRequest("Name is not valid"));
                }

                var director = await _repository.GetDirectorByNameAsync(firstName, lastName);

                if (director == null)
                {
                    return(BadRequest("Director doesn't exist in db"));
                }

                _repository.Delete(director);

                if (await _repository.SaveChangesAsync())
                {
                    return(Ok($"Director {firstName} {lastName} was deleted"));
                }
                return(StatusCode(StatusCodes.Status500InternalServerError, "It looks like no changes were made"));
            }
            catch (Exception)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, "Database failure"));
            }
        }
コード例 #6
0
 private void btnSil_Click(object sender, EventArgs e)
 {
     _filmRepo.Delete((int)dgvFilmler.CurrentRow.Cells[0].Value);
     if (_filmRepo.Save() > 0)
     {
         MessageBox.Show("Kayıt başarıyla silindi!");
     }
     DataGridViewDoldur();
 }
コード例 #7
0
        public ActionResult <Film> DeleteMovie(int id)
        {
            Film film = _filmRepo.GetBy(id);

            if (film == null)
            {
                return(NotFound());
            }
            _filmRepo.Delete(film);
            _filmRepo.SaveChanges();
            return(film);
        }
コード例 #8
0
        public ResultModel <Film> FilmDelete(Film model)
        {
            int id = model.FilmID;

            _filmRepository.Delete(id);
            return(new ResultModel <Film>
            {
                Errors = null,
                IsValid = true,
                Message = "Silme Başarılı"
            });
        }
コード例 #9
0
        public Film Delete(int id)
        {
            var value = repository.Delete(id);

            if (value == null)
            {
                return(null);
            }
            else
            {
                return(value);
            }
        }
コード例 #10
0
        public IHttpActionResult DeleteFilm(int id)
        {
            Film film = _filmRepository.GetById(id);

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

            _filmRepository.Delete(film);

            return(Ok(film));
        }
コード例 #11
0
 public bool Delete(int?Id)
 {
     if (Id == null)
     {
         Console.WriteLine("Insert Id");
         Console.Read();
     }
     else if (Id == ' ')
     {
         Console.WriteLine("Dont Insert Blank Caracter");
         Console.Read();
     }
     else
     {
         status = _filmRepository.Delete(Id);
         Console.WriteLine("Success");
     }
     return(status);
 }
コード例 #12
0
        public async Task <IActionResult> Delete(int id)
        {
            var user = await _userManager.GetUserAsync(User);

            var film = await _filmRepository.GetById(id);

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

            if (user == null || user.Id != film.UserId)
            {
                return(Forbid());
            }

            await _filmRepository.Delete(film);

            return(RedirectToAction("Index", new { pageNum = 1, pageSize = PageSize }));
        }
コード例 #13
0
 public int DeleteFilm(Film film)
 {
     return(_filmRepository.Delete(film));
 }
コード例 #14
0
 public void Delete(Entities.Film item)
 {
     _filmRepository.Delete(item);
 }
コード例 #15
0
ファイル: FilmServiceClient.cs プロジェクト: Hazrae/WPF_Plus
 public void Delete(int id)
 {
     _GlobalService.Delete(id);
 }
コード例 #16
0
 public void Delete(Film entity)
 {
     _filmRepository.Delete(entity);
 }
コード例 #17
0
 public void Delete(Film entity) => _inner.Delete(entity);
コード例 #18
0
 public Film Delete(Film film)
 {
     return(_filmRepository.Delete(film));
 }
コード例 #19
0
        public async Task <IActionResult> DeleteConfirmed(int id)
        {
            await _repository.Delete(id);

            return(RedirectToAction("Index"));
        }