コード例 #1
0
 public void AddExpense(ExpenseDto expense)
 {
     expenseRepository.Add(expense.ToExpense());
 }
コード例 #2
0
 public void UpdateExpense(ExpenseDto expense)
 {
     expenseRepository.Update(expense.ToExpense());
 }
コード例 #3
0
        public ActionResult Manage(ManageExpenseVM modelVm)
        {
            try
            {
                try
                {
                    if (ModelState.IsValid)
                    {
                        var modelDto = new ExpenseDto
                        {
                            Id = modelVm.Id,
                            ProjectId = modelVm.ProjectId,
                            Description = modelVm.Description,
                            Amount = modelVm.Amount,
                            ExpenseDate = modelVm.ExpenseDate,
                            Name = modelVm.ExpenseName,
                            Notes = modelVm.Notes
                        };

                        if (modelVm.Id > 0)
                        {
                            expenseService.UpdateExpense(modelDto);
                        }
                        else
                        {
                            expenseService.AddExpense(modelDto);

                        }
                    }

                }
                catch (Exception)
                {
                    ///TODO:Add exception handler
                    throw;
                }
                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }