public IActionResult DeleteRenter(string id) { Renters r = rentersLogic.GetOneRenter(id); Cars c = carsLogic.GetOneCar(r.CarId); if (c != null) { c.Available = true; } carsLogic.Save(); r.CarId = null; rentersLogic.DeleteRenter(id); return(RedirectToAction(nameof(ListRenters))); }
public void TestDeletingRenter() { Mock <IRepository <Renters> > renterRepo = new Mock <IRepository <Renters> >(); Renters renter = new Renters() { RenterId = Guid.NewGuid().ToString(), Name = "Kiss Gabor", PostalCode = "4034", City = "Debrecen", Address = "Elso utca 1.", Email = "*****@*****.**", PhoneNumber = "+31 880 308 7288", RentedDays = 11 }; renterRepo.Setup(repo => repo.Delete(It.IsAny <string>())); RentersLogic logic = new RentersLogic(renterRepo.Object); logic.DeleteRenter(renter.RenterId); renterRepo.Verify(repo => repo.Delete(renter.RenterId), Times.Once); }
public void DeleteRenter(string renterid) { rLogic.DeleteRenter(renterid); }