public async Task Update(FuelReceipt receipt) { var results = await firebase.Child(node).OnceAsync <FuelReceipt>(); var receiptDb = results.FirstOrDefault(r => r.Object.Id == receipt.Id); await firebase.Child(node).Child(receiptDb.Key).PutAsync <FuelReceipt>(receipt); }
public async Task Add(FuelReceipt receipt) { var receipts = await GetAll(); receipt.Id = receipts.Count() != 0 ? receipts.Max(r => r.Id) + 1 : 1; await firebase.Child(node).PostAsync <FuelReceipt>(receipt); }
public void ValidTest() { //Arrange //Act FuelReceipt receipt = new FuelReceipt() { FueledCarId = 1, RefuelingDate = new DateTime(DateTime.Now.Year, 2, 1), PetrolStationName = "Shell", FuelType = TypeOfFuel.LPG, FuelPrice = 2.34M, FuelAmount = 44.05M, DistanceFromLastRefueling = 481, Comment = "Testowy paragon" }; //Assert Assert.AreEqual(1, receipt.Id); Assert.AreEqual(1, receipt.FueledCarId); Assert.AreEqual(new DateTime(DateTime.Now.Year, 2, 1), receipt.RefuelingDate); Assert.AreEqual("Shell", receipt.PetrolStationName); Assert.AreEqual(TypeOfFuel.LPG, receipt.FuelType); Assert.AreEqual(2.34M, receipt.FuelPrice); Assert.AreEqual(44.05M, receipt.FuelAmount); Assert.AreEqual(481, receipt.DistanceFromLastRefueling); Assert.AreEqual("Testowy paragon", receipt.Comment); }
public async Task <ActionResult> Create(FuelReceipt fuelReceipt) { if (ModelState.IsValid) { await dbReceipt.Add(fuelReceipt); return(RedirectToAction("Index", new { id = fuelReceipt.FueledCarId })); } return(RedirectToAction("Create", new { id = fuelReceipt.FueledCarId })); }
public void ReceiptAddsFuel() { //Arrange FuelTank tank = new FuelTank("Unleaded", 1000); ICommand receipt = new FuelReceipt(tank, 500); //Act receipt.Execute(); //Assert Assert.AreEqual(tank.FuelLevel, 1500); }
public void ManagerHasNoPending() { //arrange FuelManager manager = new FuelManager(); FuelTank tank = new FuelTank("Unl", 1000); FuelReceipt reciept = new FuelReceipt(tank, 100); manager.Commands.Add(reciept); //act manager.ExecuteCommands(); //assert Assert.AreEqual(false, manager.HasPendingCommands()); }
public static FuelReceiptViewModel ToViewModel(this FuelReceipt entity) { return(entity.MapTo <FuelReceipt, FuelReceiptViewModel>()); }