public IActionResult Create([Bind("EventTypeName")] EventTypeAddViewModel form, string returnUrl) { if (!ModelState.IsValid) { ViewData["ActiveMenu"] = "Admin"; ViewData["ActiveLink"] = "EventTypeCreate"; ViewData["Title"] = "Create Event Type: Error"; ViewBag.ReturnUrl = returnUrl; return(View(form)); } else { if (!_eventService.CreateEventType(form.EventTypeName, out string response)) { ModelState.AddModelError("", response); ViewData["ActiveMenu"] = "Admin"; ViewData["ActiveLink"] = "EventTypeCreate"; ViewData["Title"] = "Create Event Type: Error"; ViewBag.ReturnUrl = returnUrl; return(View(form)); } else { if (!string.IsNullOrEmpty(returnUrl)) { return(Redirect(returnUrl)); } else { return(RedirectToAction(nameof(Index))); } } } }
public IActionResult Create(string returnUrl) { EventTypeAddViewModel vm = new EventTypeAddViewModel(); ViewData["ActiveMenu"] = "Admin"; ViewData["ActiveLink"] = "EventTypeCreate"; ViewData["Title"] = "Create Event Type"; ViewBag.ReturnUrl = returnUrl; return(View(vm)); }