public ActionResult AddItemToChecklist(string upc, string newCheckItem)
        {
            Trello t     = new Models.Trello();
            var    cards = t.GetCards(SessionVariables.CurrentLocation.ToString());

            foreach (var card in cards)
            {
                if (card.name == upc)
                {
                    var checklists = t.GetChecklists(card.id);
                    //var checklist = checklists.First().checkItems;
                    var result = t.PostCardChecklistItem(checklists.Last().id, newCheckItem);
                }
            }

            return(RedirectToAction("UpdateRepair", new { upc = upc }));
        }
        public ActionResult RequestRepair(string upc, string description, string duedate)
        {
            if (upc == null || description == null)
            {
                TempData["message"] = "To submit a request for repair, you must include both a valid UPC and a description of the issue to be resolved. Please try again.";
                return(RedirectToAction("Index"));
            }

            bool   success = false;
            Trello t       = new Models.Trello();

            // get card id first
            var    cards  = t.GetCards(SessionVariables.CurrentLocation.ToString());
            string cardId = null;

            foreach (var card in cards)
            {
                if (card.name == upc)
                {
                    cardId = card.id;
                    continue;
                }
            }

            if (cardId != null)
            {
                var user = db.tb_CSULabTechs.FirstOrDefault(m => m.ENAME == SessionVariables.CurrentUserId);
                // submit request by creating a new checklist on the card and adding the description as a comment
                description = description + "  -- Posted by: " + user.First_Name + " " + user.Last_Name + " (" + DateTime.Now.ToString() + ")";
                var commentId   = t.PostCardComment(cardId, description);
                var checklistId = t.PostCardChecklist(cardId, DateTime.Now.ToString());

                DateTime newDate;
                if (duedate == "")
                {
                    newDate = DateTime.Now.Date.AddDays(14);
                }
                else
                {
                    newDate = Convert.ToDateTime(duedate).Date;
                }

                string newDueDate    = t.PutNewDueDate(cardId, newDate);
                string checkItem1    = t.PostCardChecklistItem(checklistId, "Diagnose");
                string checkItem2    = t.PostCardChecklistItem(checklistId, "Resolve issue");
                var    dueDateOpened = t.PutOpenDueDate(cardId);


                if (commentId != null && checklistId != null && newDueDate != null) // id's were returned, so success
                {
                    success = true;
                }
            }

            if (success) // success
            {
                TempData["message"] = "Item " + upc + " was submitted for repair.";
                return(RedirectToAction("Index"));
            }
            else
            {
                TempData["message"] = "There was a problem submitting this request. Please try again.";
                return(RedirectToAction("Index"));
            }
        }