Exemplo n.º 1
0
        public ActionResult Edit(int id)
        {
            var expenseCategory = _expenseCategoryRepository.FindById(id).MapToView();

            if (expenseCategory == null)
            {
                return(HttpNotFound());
            }

            return(PartialView("_ExpenseCategoryForm", expenseCategory));
        }
Exemplo n.º 2
0
        public ActionResult DownloadAsPDF(int id)
        {
            var travelReport = _travelReportRepository.FindById(id).MapToView();

            // Employee info
            var employee   = _applicationUserRepository.FindById(travelReport.EmployeeId).MapToView();
            var costCenter = _costCenterRepository.FindById(employee.CostCenterId).MapToView();
            var superior   = _applicationUserRepository.FindById(employee.SuperiorId).MapToView();

            employee.CostCenter   = costCenter;
            employee.Superior     = superior.MapToModel();
            travelReport.Employee = employee;

            // TravelReport info
            var country = _countryAllowanceRepository.FindById(travelReport.CountryAllowanceId).MapToView();

            travelReport.Country = country;
            if (travelReport.DepositAmount == null)
            {
                travelReport.DepositAmount = 0;
            }
            var vehicle = _vehicleRepository.GetAllFromDatabaseEnumerable().Where(v => v.Id == travelReport.VehicleId).SingleOrDefault().MapToView();

            if (vehicle == null)
            {
                travelReport.CompanyVehicle = new VehicleVM();
            }
            else
            {
                travelReport.CompanyVehicle = vehicle;
            }

            // Expense info
            var expenses = travelReport.Expenses.Where(e => e.TravelReportId == travelReport.Id).ToList();

            foreach (var expense in expenses)
            {
                expense.ExpenseCategory = _expenseCategoryRepository.FindById(expense.ExpenseCategoryId).MapToView();

                if (expense.ExpenseCategoryId == 1 || expense.ExpenseCategoryId == 10) // allowance or private car transportation
                {
                    expense.OfficialCurrency = "HRK";
                }
                else
                {
                    expense.OfficialCurrency = _countryAllowanceRepository.FindById(int.Parse(expense.OfficialCurrency)).OfficialCurrency; // not a foreign key
                }
            }

            return(new ViewAsPdf("Print", travelReport));
        }