public CostPresentationStub(expense_item dbItem) { ExpenseItemCategory category = (ExpenseItemCategory)Enum.Parse(typeof(Common.Enums.ExpenseItemCategory), dbItem.category); this.IdExpenseItem = dbItem.id; this.IdExpense = dbItem.id_expense; this.Category = new EnumHelper().GetEnumDescription(category); this.Value = dbItem.value; if (category == ExpenseItemCategory.OTHER) { this.Description = dbItem.description; } this.Id = dbItem.expense.id; this.IdRent = dbItem.expense.id_rent; this.IdCustomer = dbItem.expense.rent.id_customer; this.StartDate = dbItem.expense.rent.start_rent; this.FinishDate = dbItem.expense.rent.finish_rent; }
public CostPresentationStub(expense dbItem) { List <expense_item> expenseItemList = dbItem.expense_item.ToList(); this.Id = dbItem.id; this.IdRent = dbItem.id_rent; this.IdCustomer = dbItem.rent.id_customer; this.RentCode = dbItem.rent.code; this.CustomerName = dbItem.rent.customer.name; this.CreatedTime = dbItem.created_time; this.Date = dbItem.date; //booking data this.PhoneCustomer = dbItem.rent.customer.phone_number; this.EmailCustomer = dbItem.rent.customer.email; this.CarModel = dbItem.rent.car_model.name; this.Destination = dbItem.rent.pickup_location; this.StartDate = dbItem.rent.start_rent; this.FinishDate = dbItem.rent.finish_rent; //expense item foreach (expense_item r in expenseItemList.Where(n => n.id_expense == dbItem.id).ToList()) { ExpenseItemCategory category = (ExpenseItemCategory)Enum.Parse(typeof(Common.Enums.ExpenseItemCategory), r.category); // value mobil if (category == ExpenseItemCategory.VEHICLE) { this.Car = ExpenseItemCategory.VEHICLE.ToString(); this.ValueVehicle = expenseItemList.Where(x => x.category == ExpenseItemCategory.VEHICLE.ToString()).Select(x => x.value).FirstOrDefault(); } if (category == ExpenseItemCategory.DRIVER) { this.Driver = ExpenseItemCategory.DRIVER.ToString(); this.ValueDriver = expenseItemList.Where(x => x.category == ExpenseItemCategory.DRIVER.ToString()).Select(x => x.value).FirstOrDefault(); } if (category == ExpenseItemCategory.GAS) { this.Gas = ExpenseItemCategory.GAS.ToString(); this.ValueGas = expenseItemList.Where(x => x.category == ExpenseItemCategory.GAS.ToString()).Select(x => x.value).FirstOrDefault(); } if (category == ExpenseItemCategory.TOLL) { this.Toll = ExpenseItemCategory.TOLL.ToString(); this.ValueToll = expenseItemList.Where(x => x.category == ExpenseItemCategory.TOLL.ToString()).Select(x => x.value).FirstOrDefault(); } if (category == ExpenseItemCategory.PARKING) { this.Parking = ExpenseItemCategory.PARKING.ToString(); this.ValueParking = expenseItemList.Where(x => x.category == ExpenseItemCategory.PARKING.ToString()).Select(x => x.value).FirstOrDefault(); } if (category == ExpenseItemCategory.OTHER) { this.Other = ExpenseItemCategory.OTHER.ToString(); this.ValueOther = expenseItemList.Where(x => x.category == ExpenseItemCategory.OTHER.ToString()).Select(x => x.value).FirstOrDefault(); } this.Description = r.description; } }