public ActionResult Index() { var model = new CalendarIndexViewModel() { Calendars = _unitOfWork.CalendarRepository.GetAll().ToList() }; return View(model); }
public ActionResult Index(CalendarIndexViewModel model) { if (ModelState.IsValid) { try { _unitOfWork.CalendarRepository.Add(model.Calendar); _unitOfWork.Save(); return RedirectToAction("Index"); } catch (Exception e) { this.Logger.ErrorFormat(e.ToString()); ModelState.AddModelError("", "An error occured."); //TODO: add custom factory to not silently handle errors in debug? } } model.Calendars = _unitOfWork.CalendarRepository.GetAll(); return View(model); }