public IActionResult Edit(int id, Distributor distributor) { if (id != distributor.DistributorId) { return(NotFound()); } if (ModelState.IsValid) { try { _distributorService.Edit(distributor); TempData["Info"] = "Dane dytrybutory zostały zaktualizowane"; } catch (DbUpdateConcurrencyException) { if (!_distributorService.DistributorExists(distributor.DistributorId)) { return(NotFound()); } else { TempData["Warning"] = "Wystąpił błąd podczas edycji dystrybutora"; throw; } } return(RedirectToAction(nameof(Index))); } return(View(distributor)); }
public void EditDistributor_Valid() { //arrange var distributorUpdated = new Distributor { BODS_Id = Guid.Parse("5df458a8-a743-4e81-bf0d-bd874f6f0cd3"), BODS_FullName = "Edit Full Name", BODS_Status = 3 }; IDistributorService service = new DistributorService(); //Act var response = service.Edit(new List <Distributor> { distributorUpdated }); var distributor = ((List <Distributor>)response).Find(x => x.BODS_Id == new Guid(("5df458a8-a743-4e81-bf0d-bd874f6f0cd3"))); //Assert Assert.AreEqual("Edit Full Name", distributor.BODS_FullName); }