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")); } }
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"); }
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 }); } }
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")); } }
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(); }
public ActionResult <Film> DeleteMovie(int id) { Film film = _filmRepo.GetBy(id); if (film == null) { return(NotFound()); } _filmRepo.Delete(film); _filmRepo.SaveChanges(); return(film); }
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ı" }); }
public Film Delete(int id) { var value = repository.Delete(id); if (value == null) { return(null); } else { return(value); } }
public IHttpActionResult DeleteFilm(int id) { Film film = _filmRepository.GetById(id); if (film == null) { return(NotFound()); } _filmRepository.Delete(film); return(Ok(film)); }
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); }
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 })); }
public int DeleteFilm(Film film) { return(_filmRepository.Delete(film)); }
public void Delete(Entities.Film item) { _filmRepository.Delete(item); }
public void Delete(int id) { _GlobalService.Delete(id); }
public void Delete(Film entity) { _filmRepository.Delete(entity); }
public void Delete(Film entity) => _inner.Delete(entity);
public Film Delete(Film film) { return(_filmRepository.Delete(film)); }
public async Task <IActionResult> DeleteConfirmed(int id) { await _repository.Delete(id); return(RedirectToAction("Index")); }