private Developer AddTagsToDeveloper(Developer developer, string tagsString)
 {
     var tagNames = Regex.Split(tagsString, ", ");
     foreach (string tagName in tagNames.Where(t => !String.IsNullOrEmpty(t)))
     {
         var tag = _tagRepository.GetByName(tagName);
         developer.Tags.Add(tag);
     }
     return developer;
 }
        public ActionResult Create(Developer developer, string tagsString)
        {
            AddTagsToDeveloper(developer, tagsString);

            if (ModelState.IsValid)
            {
                _developerRepository.Add(developer);
                _developerRepository.Save();
                return RedirectToAction("Index");
            }

            return View(developer);
        }
 public ActionResult Create()
 {
     var developer = new Developer();
     return View(developer);
 }
Exemple #4
0
        public FakeData()
        {
            _ticket1 = new Ticket
                           {
                               TicketId = 1,
                               Tags = new List<Tag>
                                          {
                                            new Tag{Name = "jquery"}
                                          }
                           };
            _ticket2 = new Ticket
                           {
                               TicketId = 2,
                               Tags = new List<Tag>
                                          {
                                              new Tag{Name="database"}
                                          }
                           };
            _ticket3 = new Ticket
                           {
                               TicketId = 3,
                               Tags = new List<Tag>
                                          {
                                              new Tag{Name="asp.net-mvc"},
                                              new Tag{Name= "c#"}
                                          }
                           };
            _ticket4 = new Ticket
                {
                    TicketId = 4,
                    Tags = new List<Tag>
                               {
                                   new Tag{Name="css"}
                               }
                };

            _tickets = new List<Ticket> { _ticket1, _ticket2, _ticket3, _ticket4 };

            _homer = new Developer
                {
                    DeveloperId = 1,
                    Tags = new List<Tag>
                               {
                                   new Tag{Name="jquery"},
                                   new Tag{Name = "javascript"},
                                   new Tag{Name="css"}
                               }
                };
            _ned = new Developer
                 {
                     DeveloperId = 2,
                     Tags = new List<Tag>
                                {
                                    new Tag{Name="c#"},
                                    new Tag{Name="asp.net-mvc"},
                                    new Tag{Name="database"}
                                }
                 };

            _developers = new List<Developer> { _homer, _ned };
        }