示例#1
0
        public List <labItems> GetItemsForLabs(string id)
        {
            string userID = GetUserID();

            var model = new ViewLab();


            //here i am getting the list of equipments in the labs
            DocumentReference   document      = db.Collection("users").Document(userID).Collection("labs").Document(id);
            CollectionReference collection    = db.Collection("users").Document(userID).Collection("labs").Document(id).Collection("equipments");
            Query           query2            = collection;
            QuerySnapshot   equipmentSanpshot = query2.GetSnapshotAsync().GetAwaiter().GetResult();
            List <labItems> labItemsAdded     = new List <labItems>();

            foreach (DocumentSnapshot queryResult in equipmentSanpshot)
            {
                labItemsAdded.Add(new labItems
                {
                    name         = queryResult.GetValue <string>("itemName"),
                    description  = queryResult.GetValue <string>("description"),
                    room         = queryResult.GetValue <string>("room"),
                    id           = queryResult.Id,
                    sub_location = queryResult.GetValue <string>("sublocation"),
                    location     = queryResult.GetValue <string>("location"),
                    pictureUrl   = queryResult.GetValue <string>("pictureUrl"),
                    quantity     = queryResult.GetValue <int>("quantity")
                });
            }

            model.LabItems = labItemsAdded;


            return(model.LabItems);
        }
示例#2
0
        public ActionResult PreviewLab(string id)
        {
            var model = new ViewLab();

            if (id != null)
            {
                model.ItemsAdded = _client.GetItemsForLabs(id);
                model.labDetails = _client.GetLabDetails(id);
            }
            else
            {
                model.LabItems = _client.GetAllItemsMethod2();
            }


            return(View(model));
        }
示例#3
0
        /// <summary>
        /// change this later to edit and add new lab
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult ViewLabsAsync(string id)
        {
            //await _client.FireBaseConnectAsync();
            //id = "b8qypoYQVIy24AZO2cvp";
            var model = new ViewLab();

            if (id != null)
            {
                model.ItemsAdded = _client.GetItemsForLabs(id);
                model.labDetails = _client.GetLabDetails(id);
                model.LabItems   = _client.GetAllItemsMethod2();
            }
            else
            {
                model.LabItems = _client.GetAllItemsMethod2();
            }


            return(View(model));
        }