Exemple #1
0
 public async Task <IActionResult> Post(CalorieEntryUpsertBindingModel model)
 {
     try
     {
         return(Ok(await _calorieService.AddEntryAsync(MapToCalorieEntry(model))));
     }
     catch (Exception ex)
     {
         base.LogError(ex.StackTrace);
         return(BadRequest(AppConstants.GenericErrorMsg));
     }
 }
Exemple #2
0
        private CalorieEntry MapToCalorieEntry(CalorieEntryUpsertBindingModel model)
        {
            var entry = new CalorieEntry
            {
                Id        = model.Id,
                UserId    = model.UserId,
                Calories  = model.Calories,
                Fat       = model.Fat,
                Carbs     = model.Carbs,
                Protein   = model.Protein,
                Quantity  = model.Quantity,
                EntryName = model.EntryName,
                CreatedAt = model.CreatedAt
            };

            return(entry);
        }