예제 #1
0
 public ActionResult Create(Chirp chirp)
 {
     if (ModelState.IsValid)
     {
         ChirpRepositoryService service = new ChirpRepositoryService(_chirpRepository);
         service.AddChirp(chirp);
         return RedirectToAction("Index", "Home");
     }
     return View(chirp);
 }
예제 #2
0
 public void AddChirp(Chirp newChirp)
 {
     string[] tokens = newChirp.Value.Split(new char[] { ' ' });
     for (int tokenCount = 0; tokenCount < tokens.Length; tokenCount++)
     {
         if (tokens[tokenCount].StartsWith("#"))
         {
             newChirp.Tags.Add(new ChirpTag { Tag = tokens[tokenCount] });
         }
     }
     _repository.AddChirp(newChirp);
 }