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()); }
public async Task <IActionResult> Booking(int labID) { Laboratory lab = LabDB.GetByID(labID); ViewData["LabInfo"] = lab; List <int> itemSet = await ItemDB.GetItemSetByLabIDAsync(labID); List <string> itemSetNames = new List <string>(); foreach (var item in itemSet) { itemSetNames.Add(((ItemTypes)item).ToString()); } TempData["LabID"] = lab.uuid; ViewData["LabItemSet"] = itemSet; return(View()); }
public async Task <IActionResult> Detail(int labID) { Laboratory labDetail = LabDB.GetByID(labID); List <ItemDetail> itemDetails = await ItemDB.GetAllDetailByLabIDAsync(labID); List <int> itemSet = await ItemDB.GetItemSetByLabIDAsync(labID); List <int> itemQuantity = await ItemDB.GetAllQuantityByLabIDAsync(labID); itemDetails.ForEach(item => { if (!itemSet.Contains(item.type)) { itemSet.Add(item.type); } }); ViewData["LabDetail"] = labDetail; ViewData["ItemSet"] = itemSet; ViewData["ItemQuantity"] = itemQuantity; ViewData["LabID"] = labID; return(View()); }
public ActionResult <Laboratory> Gets(int labID) { return(LabDB.GetByID(labID)); }