public CiterneCard(Citerne citerne) { CiterneGuid = citerne.CiterneGuid; Libel = citerne.Libel; Fuel = citerne.Fuel.Libel; var curBalance = CiternesManager.StaticGetCiterneFuelBalance(citerne.CiterneGuid).Result; CurrentStock = curBalance.ToString("0.##\\L") + " en stock /" + citerne.MaxCapacity.ToString("0.##\\L") ; Pourcentage = ((curBalance * 100)/citerne.MaxCapacity).ToString("0.##\\%"); //FuelPrice = FuelManager.GetFuelCurrentPrice(citerne.Fuel.FuelGuid).ToString("0.##\\dhs/L"); }
public async Task<bool> Put(Citerne myCiternes) { using (var db = new StationContext()) { myCiternes.LastEditDate = DateTime.Now; db.Citernes.Attach(myCiternes); db.Entry(myCiternes).State = EntityState.Modified; return await db.SaveChangesAsync() > 0; } }
public async Task<bool> Post(Citerne myCiternes) { using (var db = new StationContext()) { if (myCiternes.CiterneGuid == Guid.Empty) myCiternes.CiterneGuid = Guid.NewGuid(); myCiternes.DateAdded = DateTime.Now; myCiternes.LastEditDate = DateTime.Now; db.Citernes.Add(myCiternes); return await db.SaveChangesAsync() > 0; } }