public async void TestForDeleteVendor() { var options = new DbContextOptionsBuilder <LeagueContext>() .UseInMemoryDatabase(databaseName: "p3VendorControllerDeleteVendor") .Options; using (var context = new LeagueContext(options)) { context.Database.EnsureDeleted(); context.Database.EnsureCreated(); Repo r = new Repo(context, new NullLogger <Repo>()); Logic logic = new Logic(r, new NullLogger <Repo>()); VendorController vendorController = new VendorController(logic); var vendor = new Vendor { VendorID = Guid.NewGuid(), VendorInfo = "chicken tenders", VendorName = "bojangles" }; var deleteVendor = await vendorController.DeleteVendor(vendor.VendorID); Assert.IsAssignableFrom <string>((deleteVendor as NotFoundObjectResult).Value); r.Vendors.Add(vendor); await r.CommitSave(); var deleteVendor2 = await vendorController.DeleteVendor(vendor.VendorID); Assert.IsAssignableFrom <bool>((deleteVendor2 as OkObjectResult).Value); } }
/// ----------------------------------------------------------------------------- /// <summary> /// cmdDelete_Click runs when the Delete button is clicked. /// </summary> /// <remarks> /// </remarks> /// <history> /// [cnurse] 9/17/2004 Updated to reflect design changes for Help, 508 support /// and localisation /// </history> /// ----------------------------------------------------------------------------- protected void OnDeleteClick(object sender, EventArgs e) { try { if (VendorID != -1) { var objVendors = new VendorController(); objVendors.DeleteVendor(VendorID); } Response.Redirect(Globals.NavigateURL()); } catch (Exception exc) //Module failed to load { Exceptions.ProcessModuleLoadException(this, exc); } }