public async Task <IActionResult> Create(EventViewModel model) { if (ModelState.IsValid) { var tags = new List <Tag>(); if (!string.IsNullOrEmpty(model.SelectedTags)) { tags = (await tagsService.ParseTags(model.SelectedTags)).ToList(); } model.Event.User = await userManager.GetUserAsync(User); model.Event.EventTags = tags.Select(t => new EventTag { Tag = t }).ToList(); model.Event.Created = DateTime.Now; await eventsRepository.CreateAsync(model.Event); return(RedirectToAction("Detail", new { id = model.Event.Id })); } TempData.AddErrorMessage("Vyplňte všechna pole."); return(View("Create", model)); }