private void ParseHouseMateExpenseFields(HouseMateExpense houseMateExpense, HouseMateExpenseBindingModel model)
 {
     houseMateExpense.ExpenseId    = model.ExpenseId;
     houseMateExpense.HouseMateId  = model.HouseMateId;
     houseMateExpense.IsMarkedPaid = model.IsMarkedPaid;
     houseMateExpense.IsPaid       = model.IsPaid;
 }
        public IActionResult UpdateHouseMateExpense([FromRoute] string houseMateId, int expenseId, [FromBody] HouseMateExpenseBindingModel model)
        {
            if (ModelState.IsValid)
            {
                if (houseMateId != model.HouseMateId || expenseId != model.ExpenseId)
                {
                    throw new Exception("one or more route parameters do not match model values");
                }

                try
                {
                    HouseMateExpense houseMateExpense = _houseMateService.GetHouseMateExpense(houseMateId, expenseId);
                    ParseHouseMateExpenseFields(houseMateExpense, model);
                    _houseMateService.UpdateHouseMateExpense(houseMateExpense);

                    return(Ok(houseMateExpense));
                }
                catch (Exception)
                {
                    throw new Exception("There was an error updating the HouseMateExpense");
                }
            }

            return(BadRequest("There was an error updating the HouseMateExpense"));
        }