public async Task <PartialViewResult> Delete(Guid idTruck) { await _truckService.DeleteTruck(idTruck); var list = await _truckService.ListAllTrucks(); return(await PartialViewAsync("_ListTrucks", list)); }
public IActionResult Delete([Bind] TruckViewModel truck) { if (truck != null && truck.TruckId != null && truck.TruckId != 0) { _service.DeleteTruck((int)truck.TruckId); } return(RedirectToAction("ListTrucks")); }
public JsonResult Delete(string Id) { try { _truckService.DeleteTruck(Id); return(Json(Id, JsonRequestBehavior.AllowGet)); } catch (Exception) { throw; } }
public void Delete(string id) { _truckService.DeleteTruck(id); }
public async Task DeleteTruck([FromQuery] int truckId) { await _truckService.DeleteTruck(truckId); }
public void TruckServiceFunctions() { ITruckService _service = serviceProvider.GetService <ITruckService>(); List <TruckModel> models = _service.ListAvailableModels(); Assert.NotNull(models); Assert.AreEqual(2, models.Count); // Get first available model var model = models[0]; // Saving new Truck with specific information Truck truck = new Truck() { Description = "TEST", ManufacturingYear = 1944, ModelYear = 1944, Model = model, TruckModelId = model.TruckModelId }; List <Truck> receivedTrucks = _service.ListAllTrucks(); List <Truck> filtered = receivedTrucks.Where(t => t.ManufacturingYear == 1944 || t.ModelYear == 1944).ToList(); Assert.AreEqual(0, filtered.Count); _service.SaveOrUpdateTruck(truck); receivedTrucks = _service.ListAllTrucks(); filtered = receivedTrucks.Where(t => t.ManufacturingYear == 1944 || t.ModelYear == 1944).ToList(); Assert.AreEqual(1, filtered.Count); Truck saved = filtered[0]; Assert.AreEqual(1944, saved.ManufacturingYear); Assert.AreEqual(1944, saved.ModelYear); Assert.AreEqual("TEST", saved.Description); int id = saved.TruckId; Truck toUpdate = _service.FindTruckById(id); Assert.NotNull(toUpdate); toUpdate.ModelYear = 1950; _service.SaveOrUpdateTruck(toUpdate); receivedTrucks = _service.ListAllTrucks(); filtered = receivedTrucks.Where(t => t.ManufacturingYear == 1944 && t.ModelYear == 1950).ToList(); Assert.AreEqual(1, filtered.Count); Truck updated = filtered[0]; Assert.AreEqual(1944, updated.ManufacturingYear); Assert.AreEqual(1950, updated.ModelYear); Assert.AreEqual("TEST", updated.Description); _service.DeleteTruck(id); receivedTrucks = _service.ListAllTrucks(); filtered = receivedTrucks.Where(t => t.ManufacturingYear == 1944 || t.ModelYear == 1950).ToList(); Assert.AreEqual(0, filtered.Count); }
public IActionResult Delete(int id) { _service.DeleteTruck(id); return(Ok()); }
public async Task <IActionResult> DeleteTruck([FromRoute] int id) { var data = await _truckService.DeleteTruck(id); return(ApplicationResult(data, data.StatusCode)); }