public async Task <IActionResult> Detail(string?id, string?date) { int labID = Int16.Parse(id ?? "1"); DateTime datetime = DateTime.ParseExact(date ?? DateTime.Now.ToString("yyyy-MM-dd HH:mm"), "yyyy-MM-dd HH:mm", CultureInfo.InvariantCulture); Laboratory lab = LabDB.GetByID(Int16.Parse(id ?? "1")); List <LabItem> items = new List <LabItem>(); IList <ItemDetail> labItems = await ItemDB.GetAllDetailByLabIDAsync(Int16.Parse(id ?? "1")); List <List <int> > allQuantity = await LabItemDB.GetCurrentQuantityByDateAsync(datetime); List <Transaction> transactions = await TransactionDB.GetByLabIDAndDateAsync(labID, datetime); List <int> availableNumber = new List <int> { allQuantity[0][labID - 1], allQuantity[1][labID - 1] }; List <Laboratory> labList = await LabDB.GetAllAsync(); List <int> type = await ItemDB.GetItemSetByLabIDAsync(labID); Dictionary <int, string> types = await ItemDB.GetItemSetAsync(); List <string> realType = new List <string>(); for (int i = 0; i < labItems.Count; i++) { var available = 0; string am = "NO"; var pm = "NO"; for (int j = 0; j < transactions.Count; j++) { if (labItems[i].uuid == transactions[j].item_id) { available = transactions[j].time_id; } } var pmm = 1 & (available >> 1); var amm = 1 & available; am = amm == 0 ? "YES" : "NO"; pm = pmm == 0 ? "YES" : "NO"; items.Add(new LabItem(labItems[i].uuid.ToString(), labItems[i].name, am, pm)); } foreach (var it in types) { realType.Add(it.Value.Substring(0, it.Value.Length - 2)); } ViewData["LabItems"] = items; ViewData["Title"] = labList; ViewData["Description"] = lab.description; ViewData["LabID"] = id; ViewData["Date"] = datetime.ToString("yyyy-MM-dd"); ViewData["Available"] = availableNumber; ViewData["Type"] = realType; ViewData["EnableType"] = type; return(View()); }