public async Task AddArticle(AddArticleCommand command) { var article = new Article { ArticleContent = command.Content }; _context.Articles.Add(article); await _context.SaveChangesAsync(); }
public async Task AddEating(AddEatingCommand command) { var eating = _context.Eatings.FirstOrDefault(e => e.Date == command.Date); if (eating != null) { eating.CaloriesSum = command.CaloriesSum; } else { Eating newEating = new Eating() { Date = command.Date, CaloriesSum = command.CaloriesSum }; _context.Eatings.Add(newEating); } await _context.SaveChangesAsync(); }
public async Task AddWeighting(AddWeightingCommand command) { var weighting = _context.Weightings.FirstOrDefault(w => w.Date == command.Date); if (weighting != null) { weighting.Weight = command.Weight; } else { Weighting newWeighting = new Weighting() { Date = command.Date, Weight = command.Weight }; _context.Weightings.Add(newWeighting); } await _context.SaveChangesAsync(); }