public async Task UpdateFoodCounterAsync(FoodCounter updateFood) { var entry = _context.Attach(updateFood); entry.State = EntityState.Modified; await _context.SaveChangesAsync(); }
public async Task <FoodCounter> InsertFoodCounterAsync(FoodCounter newFood) { _context.FoodCounters.Add(newFood); await _context.SaveChangesAsync(); return(newFood); }
public async Task <ActionResult <FoodCounter> > Post([FromBody] FoodCounter value) { if (value == null) { return(BadRequest("Üres paraméter")); } try { var temp = await _foodCounterService.InsertFoodCounterAsync(value); return(Ok(temp)); } catch (InvalidOperationException) { return(BadRequest("Sikertelen beszúrás")); } }
public async Task <IActionResult> Put([FromBody] FoodCounter value) { if (value == null) { return(BadRequest("Üres paraméter")); } try { value.Modification = DateTime.Now; await _foodCounterService.UpdateFoodCounterAsync(value); return(RedirectToAction("Food", new { id = value.Id })); } catch { string response = "Nem sikerült a változtatás"; return(StatusCode(StatusCodes.Status500InternalServerError, response)); } }
// Use this for initialization void Start() { food = FindObjectOfType <FoodCounter>(); food.foodValue += UpdateFoodUI; }