コード例 #1
0
        public async Task UpdateFoodCounterAsync(FoodCounter updateFood)
        {
            var entry = _context.Attach(updateFood);

            entry.State = EntityState.Modified;
            await _context.SaveChangesAsync();
        }
コード例 #2
0
        public async Task <FoodCounter> InsertFoodCounterAsync(FoodCounter newFood)
        {
            _context.FoodCounters.Add(newFood);

            await _context.SaveChangesAsync();

            return(newFood);
        }
コード例 #3
0
        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"));
            }
        }
コード例 #4
0
        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));
            }
        }
コード例 #5
0
 // Use this for initialization
 void Start()
 {
     food            = FindObjectOfType <FoodCounter>();
     food.foodValue += UpdateFoodUI;
 }