Beispiel #1
0
        public ActionResult Edit(Guid id)
        {
            Guid?idOwner = (User as CustomPrincipal).IdOwner;

            List <Business.Entities.rent> listRent = new List <rent>();

            if (idOwner.HasValue)
            {
                listRent = RepoRent.FindAll().Where(x => x.id_owner == idOwner.Value).ToList();
            }

            expense dbItem = RepoExpense.FindByPk(id);
            //expense_item expenseItem = new expense_item();
            List <expense_item> expenseItemList = dbItem.expense_item.Where(x => x.id_expense == dbItem.id).ToList();

            CostFormStub detailStub = new CostFormStub(dbItem, listRent);

            //mobil
            var listItemMobil = expenseItemList.Where(x => x.category == ExpenseItemCategory.VEHICLE.ToString());

            detailStub.ValueVehicle = listItemMobil.Select(x => x.value).FirstOrDefault();
            //supir
            var listItemSupir = expenseItemList.Where(x => x.category == ExpenseItemCategory.DRIVER.ToString());

            detailStub.ValueDriver = listItemSupir.Select(x => x.value).FirstOrDefault();
            //Bensin
            var listItemBBM = expenseItemList.Where(x => x.category == ExpenseItemCategory.GAS.ToString());

            detailStub.ValueGas = listItemBBM.Select(x => x.value).FirstOrDefault();
            //Tol
            var listItemTol = expenseItemList.Where(x => x.category == ExpenseItemCategory.TOLL.ToString());

            detailStub.ValueToll = listItemTol.Select(x => x.value).FirstOrDefault();
            //Parkir
            var listItemParkir = expenseItemList.Where(x => x.category == ExpenseItemCategory.PARKING.ToString());

            detailStub.ValueParking = listItemParkir.Select(x => x.value).FirstOrDefault();
            //BiayaLain
            var listItemBiaya = expenseItemList.Where(x => x.category == ExpenseItemCategory.OTHER.ToString());

            detailStub.ValueOther  = listItemBiaya.Select(x => x.value).FirstOrDefault();
            detailStub.Description = expenseItemList.Select(x => x.description).FirstOrDefault();

            return(View("Form", detailStub));
        }