public void EatFood(Food food) { try { var saved = (from foods in DbContext.Foods where foods.Id == food.Id select food).FirstOrDefault(); saved.EatenTimes++; DbContext.SubmitChanges(); } catch (Exception ex) { ErrorLogger.LogException(ex); } }
protected override void InitializeExecute() { BusyCount++; base.InitializeExecute(); var parameters = NavigationProvider.GetNavigationParameters(); if (parameters.ContainsKey(Constants.NavigationParameters.FoodId)) { RunInBackground(() => { Food result; using (var repo = new FoodRepository()) { result = repo.GetById(int.Parse(parameters[Constants.NavigationParameters.FoodId])); } InvokeInUIThread(() => { CurrentFood = result; BusyCount--; }); }); } }