Пример #1
0
 public override string ParseCommand(ChatMessage msg)
 {
     string[] message = msg.Message.Split(' ');
     if (message.Length > 1)
     {
         string itemName = msg.Message.Replace("!" + COMMAND + " ", "");
         if (itemName.Length >= 4)
         {
             List <Thing> matching = null;
             if (itemName.StartsWith("\"") && itemName.EndsWith("\""))
             {
                 matching = ThingSelection.GetAllStoredThingsThatExactMatch(itemName.Replace("\"", ""));
             }
             else
             {
                 matching = ThingSelection.GetAllStoredThingsThatContain(itemName);
             }
             if (matching != null && matching.Count > 0)
             {
                 return(GetPrettyItemCount(matching));
             }
             else
             {
                 return("The item " + itemName + " was not found.");
             }
         }
         else
         {
             return("The item name is too short, it must be at least 4 characters.");
         }
     }
     return(null);
 }
Пример #2
0
        public override string ParseCommand(ChatMessage msg)
        {
            List <Thing> matching = ThingSelection.GetAllStoredFood();

            if (matching != null && matching.Count > 0)
            {
                return(GetPrettyItemCount(matching));
            }
            return(null);
        }
Пример #3
0
        public ActionResult SelectThing(ThingSelection model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var service = CreateThingService();

            ViewBag.Catagories   = service.CatagoriesToList();
            model.ThingsSelected = service.GetSelectedThing(model);
            return(View(model));
        }
Пример #4
0
        public override string ParseCommand(ChatMessage msg)
        {
            List <Thing> drugs = ThingSelection.GetAllStoredNonMedicalDrugs();

            if (drugs != null && drugs.Count > 0)
            {
                return(GetPrettyDrugs(drugs));
            }
            else
            {
                return("No drugs are currently in storage.");
            }
        }
Пример #5
0
 public IEnumerable <ThingListItem> GetSelectedThing(ThingSelection model)
 {
     using (var ctx = new ApplicationDbContext())
     {
         var query = ctx
                     .Things
                     .Where(e => e.OwnerId == _userId && e.CatagoryId == model.CatagoryId && e.TimeAllotted <= model.TimeAllotted && e.IsCompleted.Equals(false))
                     .Select(s => new ThingListItem
         {
             ThingId     = s.ThingId,
             CatagoryId  = s.CatagoryId,
             Catagory    = s.Catagory,
             Heading     = s.Heading,
             TimeAlloted = s.TimeAllotted,
             IsCompleted = s.IsCompleted,
             CreatedUtc  = s.CreatedUtc
         }
                             );
         return(query.ToArray());
     }
 }
        private bool AllowsThingSelection(ThingSelection selection, Thing thing)
        {
            if (selection == ThingSelection.None)
            {
                return(false);
            }
            else if (selection == ThingSelection.NeedsHauling)
            {
                return(thing.Map.listerHaulables.ThingsPotentiallyNeedingHauling().Contains(thing));
            }
            else if (selection == ThingSelection.Selectable)
            {
                return(ThingSelectionUtility.SelectableByMapClick(thing));
            }
            else if (selection == ThingSelection.Everything)
            {
                return(true);
            }

            return(false);
        }