public ActionResult Create(string topic) { Event evt = new Event(); evt.Topic = topic; evt.Start = DateTime.Now; evt.End = DateTime.Now.AddHours(1); ViewData["categories"] = new SelectList(_categoryRepository.FindByType("evt"), "ID", "Name", _categoryRepository.GetByIndex(0)); return View(evt); }
public ActionResult Create(Event evt, int categoryId) { if (ModelState.IsValid) { evt.Category = _categoryRepository.GetById(categoryId); UpdateModel<Event>(evt); _eventRepository.Add(evt); UnitOfWork.Save(); return RedirectToAction("Index", "Event"); // action = BoardAndStaff } return View(evt); }
public ActionResult Edit(int id, Event evt, int categoryId) { var EventInDb = _eventRepository.GetById(id); EventInDb.Category = _categoryRepository.GetById(categoryId); if (TryUpdateModel(EventInDb)) { UnitOfWork.Save(); return RedirectToAction("Index", "Event"); } return View(evt); }