示例#1
0
        public ViewResult AddExpense() //Guid id
        {
            CarExpenseAddViewModel model = new CarExpenseAddViewModel
            {
                // CarId = id,
            };

            return(View(model));
        }
示例#2
0
 public IActionResult AddExpense(CarExpenseAddViewModel model)
 {
     if (ModelState.IsValid)
     {
         CarExpense expense = new CarExpense
         {
             CarId        = model.CarId,
             CostCategory = model.CostCategory,
             Decription   = model.Decription,
             Amount       = model.Amount,
             Date         = model.Date,
             Id           = new Guid()
         };
         if (model.IsServiceSelected)
         {
             expense.FacilityId = model.FacilityId;
         }
         _carExpensesRepository.Add(expense);
         return(RedirectToAction("details", "cars", new { guid = model.CarId }));
     }
     return(RedirectToAction("addexpense", "carexpenses", new { id = model.CarId }));
 }