예제 #1
0
 public CommonMealExpense Map(CommonMealExpenseViewModel item)
 {
     return(new CommonMealExpense
     {
         Id = item.Id,
         PersonId = item.PersonId,
         Amount = item.Amount ?? 0,
         MealId = item.MealId,
         Timestamp = item.Date
     });
 }
        public async Task <ActionResult> UpdateExpense(CommonMealExpenseViewModel expense)
        {
            var expenseModel = _commonMealExpenseMapper.Map(expense);

            if (expenseModel.Id == -1)
            {
                await _commonMealExpenseRepository.Add(expenseModel);
            }
            else
            {
                await _commonMealExpenseRepository.Update(expenseModel);
            }

            return(Ok());
        }