Ejemplo n.º 1
0
        public async Task <IActionResult> EditExpense(int?id)
        {
            ExpenseViewModel model = new ExpenseViewModel
            {
                ExpensesType = _combosHelper.GetComboExpenses()
            };

            if (id == null)
            {
                return(NotFound());
            }

            ExpenseEntity expense = await _dataContext.Expenses
                                    .Include(et => et.ExpenseType)
                                    .Include(et => et.Trip)
                                    .FirstOrDefaultAsync(e => e.Id == id);

            model.TripId      = expense.Trip.Id;
            model.Id          = expense.Id;
            model.Details     = expense.Details;
            model.PicturePath = expense.PicturePath;
            model.Value       = expense.Value;
            model.ExpenseId   = expense.ExpenseType.Id;
            model.LogoPath    = expense.ExpenseType.LogoPath;

            if (model == null)
            {
                return(NotFound());
            }

            return(View(model));
        }
        public IActionResult Create()
        {
            ExpenseViewModel model = new ExpenseViewModel
            {
                ExpensesType = _combosHelper.GetComboExpenses()
            };

            return(View(model));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> AddExpense(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var travelEntity = await _context.Travel.FindAsync(id);

            if (travelEntity == null)
            {
                return(NotFound());
            }

            var model = new ExpensesViewModel
            {
                Travel        = travelEntity,
                Travelid      = travelEntity.id,
                ExpenseTypeId = _combosHelper.GetComboExpenses()
            };

            return(View(model));
        }