private void btnEdit_Click(object sender, EventArgs e) { var product = _prService.Find(Convert.ToInt32(dataGrid.SelectedRows[0].Cells[0].Value)); if (product != null) { var dialogResult = new EditProductForm(product, _gService.GetAll()).ShowDialog(); if (dialogResult == DialogResult.OK) { _prService.Update(product); MetroMessageBox.Show(this, $"Игра {product.Title} изменена", "Справка", MessageBoxButtons.OK, MessageBoxIcon.Information); UpdateDataGrid(); UpdateCounter(); } } }
public ActionResult <IEnumerable <Genre> > GetAll() { try { return(Ok(_gs.GetAll())); } catch (System.Exception err) { return(BadRequest(err.Message)); } }
private void GenresForm_Load(object sender, System.EventArgs e) { if (Settings.CurrentUser.UserType == Core.Other.UserType.Admin) { flpEditing.Enabled = true; } else { flpEditing.Enabled = false; } var items = _genresService.GetAll(); lstGenres.Items.AddRange(items.Select(x => x.MapToItem()).ToArray()); _items = new List <Genre>(items); UpdateCounter(); }
public async Task GetAllGenresWhenCalled() { AutoMapperConfig.RegisterMappings(typeof(GenreTestModel).Assembly); var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()); var repository = new EfDeletableEntityRepository <Genre>(new ApplicationDbContext(options.Options)); await repository.AddAsync(new Genre { Id = 4, Name = "Action" }); await repository.AddAsync(new Genre { Id = 10, Name = "Comedy" }); await repository.AddAsync(new Genre { Id = 11, Name = "Drama" }); await repository.SaveChangesAsync(); var service = new GenresService(repository, null); var genresCount = service.GetAll <GenreTestModel>().Count; Assert.Equal(3, genresCount); }
public async Task GetAll_ShouldReturnValidCount() { var genres = await GenresService.GetAll(); Assert.That(genres.Count(), Is.EqualTo(Genres.Count)); }