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> Tools()
        {
            List <Laboratory> lab = await LabDB.GetAllAsync();

            List <ItemDetail> labItems = await ItemDB.GetAllDetailAsync();

            List <Laboratory> labList = await LabDB.GetAllAsync();


            ViewData["LabItems"] = labItems;
            ViewData["Title"]    = labList;
            return(View());
        }
        public async Task <IActionResult> Index()
        {
            /// get lab lists here.
            List <LabListModel> labLists = await LabDB.GetListAsync();

            /// get item transaction log here.
            List <Log> logLists = await LogDB.GetAllAsync();

            logLists.Sort((x, y) => DateTime.Compare(y.created, x.created));

            ViewData["LabLists"] = labLists;
            ViewData["LogLists"] = logLists;

            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> Index()
        {
            List <Laboratory> nameLab = await LabDB.GetAllAsync();

            List <ItemDetail> items = await ItemDB.GetAllDetailAsync();

            List <List <ItemDetail> > labItem = new List <List <ItemDetail> >();
            List <List <ItemDetail> > myType  = new List <List <ItemDetail> >();
            List <Int64> checkList            = new List <Int64>();

            for (int i = 0; i < nameLab.Count; i++)
            {
                labItem.Add(new List <ItemDetail>());
                myType.Add(new List <ItemDetail>());
            }

            for (int i = 0; i < items.Count; i++)
            {
                labItem[items[i].laboratory_id - 1].Add(items[i]);
            }

            for (int i = 0; i < labItem.Count; i++)
            {
                for (int j = 0; j < labItem[i].Count; j++)
                {
                    if (!checkList.Contains(labItem[i][j].type))
                    {
                        myType[i].Add(labItem[i][j]);
                        checkList.Add(labItem[i][j].type);
                    }
                }
                checkList.Clear();
            }

            ViewData["nameLab"] = nameLab;
            ViewData["myType"]  = myType;
            ViewData["labItem"] = labItem;

            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());
        }
Пример #7
0
 public ActionResult <Laboratory> Gets(int labID)
 {
     return(LabDB.GetByID(labID));
 }
Пример #8
0
 public async Task <ActionResult <List <Laboratory> > > Gets()
 {
     return(await LabDB.GetAllAsync());
 }