public ActionResult EventDetails(int?id) { var model = new AdminEventDetailsModel(); if (id.HasValue && Database.Instance.IsValidEventId(id.Value)) { var @event = Database.Instance.GetEventBy(id.Value); model.MapFromEntity(@event); } return(View(model)); }
public ActionResult EventDetails(AdminEventDetailsModel model) { if (ModelState.IsValid) { var @event = model.Id.HasValue ? Database.Instance.GetEventBy(model.Id.Value) : new Event(); model.MapToEntity(@event); if (model.Id.HasValue) { Database.Instance.Update(@event); } else { Database.Instance.SaveNew(@event); } return(RedirectToAction(nameof(EventOverview))); } return(View(model)); }