public override string ParseCommand(ChatMessage msg) { string[] message = msg.Message.Split(' '); if (message.Length > 1) { string def = ANIMAL_DEFS.TryGetValue(message[1]); if (def != null) { List <Pawn> matching = AnimalSelection.GetAllTameAnimalsInOrderWithDef(def); if (matching != null && matching.Count > 0) { return(GetPrettyAnimalList(matching)); } else { return("No tamed animals " + def + " found"); } } else { return("The animal " + def + " was not found. The animal type is probably misspelled."); } } return(null); }
public async Task <IActionResult> Edit(int id, [Bind("id,animalId,ownerId,farmId,selectionDate,shortNotes")] AnimalSelection animalSelection) { if (id != animalSelection.id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(animalSelection); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AnimalSelectionExists(animalSelection.id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(animalSelection)); }
public async Task <IActionResult> Create([Bind("id,animalId,ownerId,farmId,selectionDate,shortNotes")] AnimalSelection animalSelection) { if (ModelState.IsValid) { _context.Add(animalSelection); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(animalSelection)); }
public override string ParseCommand(ChatMessage msg) { string[] message = msg.Message.Split(' '); if (message.Length > 1) { string name = msg.Message.Replace("!" + COMMAND + " ", ""); List <Pawn> matching = AnimalSelection.GetAllTameAnimalsInOrderWithName(name); if (matching != null && matching.Count > 0) { return(GetPrettyAnimal(matching[0])); } else { return("Animal " + name + " not found"); } } return(null); }
private string GetPrettyAnimalCount(string animalType) { return("Total count of " + animalType + " in the colony: " + AnimalSelection.GetAllTameAnimalsInOrderWithDef(animalType).Count); }