Ejemplo n.º 1
0
 public ActionResult Edit(TopicViewModel topic)
 {
     if (ModelState.IsValid)
     {
         repository.Update(topic.ToOrm());
         return(RedirectToRoute(new { controller = "Section", Action = "Index" }));
     }
     ViewBag.Sections = new SelectList(sectionsRepository.Sections, "SectionId", "Name", topic.SectionId);
     return(View(topic));
 }
Ejemplo n.º 2
0
 public ActionResult Create(TopicViewModel topic)
 {
     if (ModelState.IsValid)
     {
         topic.CreatorId = userRepository
                           .GetUserByUsername(User.Identity.Name)
                           .UserId;
         topic.CreationDate = DateTime.Now;
         repository.Add(topic.ToOrm());
         int addedTopicId = repository.Topics
                            .Where(x => x.Name == topic.Name && x.CreatorId == topic.CreatorId)
                            .ToList().OrderBy(x => x.Creation_date).Last().TopicId;
         return(RedirectToRoute(new { controller = "Topic", Action = "Topic", id = addedTopicId, page = 1 }));
     }
     return(View(topic));
 }