public ActionResult LoadEditExpensePartial(int id, int expenseType)
        {
            var expense = _context.Expenses.Include(e => e.ExpenseType).FirstOrDefault(e => e.Id == id);

            if (expenseType == 1)
            {
                var mileageViewModel = new MileageFormViewModel();
                return(PartialView("_MileageForm", mileageViewModel));
            }
            else
            {
                var expenseViewModel = new ExpenseViewModel
                {
                    Date          = expense.Date.Value,
                    DateTime      = expense.DateTime,
                    ExpenseTypeId = expense.ExpenseTypeId,
                    ExpenseFormId = expense.ExpenseFormId,
                    Cost          = expense.Cost,
                    Description   = expense.Description,
                    Id            = expense.Id,
                    ExpenseTypes  = _context.ExpenseTypes.ToList()
                };
                return(PartialView("_OtherExpenseForm", expenseViewModel));
            }
        }
 public ActionResult LoadExpensePartial(int id)
 {
     if (id == 1)
     {
         var mileageViewModel = new MileageFormViewModel();
         return(PartialView("_MileageForm", mileageViewModel));
     }
     else
     {
         var expenseViewModel = new ExpenseViewModel();
         return(PartialView("_OtherExpenseForm", expenseViewModel));
     }
 }
        //-------------------------------------------------------------------------------------
        // Partials
        // ------------------------------------------------------------------------------------



        public ActionResult LoadMileageFormat(int id)
        {
            if (id == 1)
            {
                var viewModel = new MileageFormViewModel();
                return(PartialView("_OdometerForm", viewModel));
            }
            else
            {
                var viewModel = new MileageFormViewModel();
                return(PartialView("_GoogleMapsForm", viewModel));
            }
        }
        public ActionResult LoadEditMileageFormat(int id, int mileageFormat)
        {
            var expense = _context.Expenses.Include(e => e.ExpenseType).FirstOrDefault(e => e.Id == id);

            if (mileageFormat == 1)
            {
                var viewModel = new MileageFormViewModel
                {
                    Date          = expense.Date,
                    DateTime      = expense.DateTime,
                    ExpenseTypeId = expense.ExpenseTypeId,
                    ExpenseFormId = expense.ExpenseFormId,
                    Origin        = expense.Origin,
                    Destination   = expense.Destination,
                    OdometerStart = expense.OdometerStart,
                    OdometerEnd   = expense.OdometerEnd,
                    TotalMiles    = expense.TotalMiles,
                    Cost          = expense.Cost,
                    Id            = expense.Id,
                    ExpenseTypes  = _context.ExpenseTypes.ToList(),
                    ExpenseType   = _context.ExpenseTypes.Where(e => e.Id == expense.ExpenseTypeId).FirstOrDefault()
                };
                return(PartialView("_OdometerForm", viewModel));
            }
            else
            {
                var viewModel = new MileageFormViewModel
                {
                    Date          = expense.Date,
                    DateTime      = expense.DateTime,
                    ExpenseTypeId = expense.ExpenseTypeId,
                    ExpenseFormId = expense.ExpenseFormId,
                    Origin        = expense.Origin,
                    Destination   = expense.Destination,
                    TotalMiles    = expense.TotalMiles,
                    Cost          = expense.Cost,
                    Id            = expense.Id,
                    ExpenseTypes  = _context.ExpenseTypes.ToList(),
                    ExpenseType   = _context.ExpenseTypes.Where(e => e.Id == expense.ExpenseTypeId).FirstOrDefault()
                };

                return(PartialView("_GoogleMapsForm", viewModel));
            }
        }
        // GET: MileageForms/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            MileageForm mileageForm = db.MileageForms.Find(id);

            ViewBag.Trips = db.Trips.AsNoTracking()
                            .Where(a => a.MileageFormID == id)
                            .OrderByDescending(a => a.Date).ToList();

            var model = new MileageFormViewModel();

            model.MileageForm = mileageForm;

            if (mileageForm == null)
            {
                return(HttpNotFound());
            }
            return(View(model));
        }