public ActionResult CreateStory(ShortStoryInputViewModel shortStory) { if (!this.User.Identity.IsAuthenticated) { this.Response.StatusCode = 401; return(this.Content("Access is denied")); } shortStory.Tags = this.tags.GetAll().To <TagViewModel>(); shortStory.AuthorId = this.User.Identity.GetUserId(); if (!this.ModelState.IsValid) { return(this.View(shortStory)); } var newStory = new ShortStory() { Title = shortStory.Title, Content = shortStory.Content, AuthorId = shortStory.AuthorId }; foreach (var id in shortStory.TagIds) { newStory.Tags.Add(this.tags.GetById(id)); } this.stories.Add(newStory); var viewModel = this.Mapper.Map <ShortStoryDetailsViewModel>(newStory); return(this.RedirectToAction("Details", "ShortStories", new { id = viewModel.Id, area = "ShortStory" })); }
public ActionResult CreateStory(ShortStoryInputViewModel shortStory) { if (!this.User.Identity.IsAuthenticated) { this.Response.StatusCode = 401; return this.Content("Access is denied"); } shortStory.Tags = this.tags.GetAll().To<TagViewModel>(); shortStory.AuthorId = this.User.Identity.GetUserId(); if (!this.ModelState.IsValid) { return this.View(shortStory); } var newStory = new ShortStory() { Title = shortStory.Title, Content = shortStory.Content, AuthorId = shortStory.AuthorId }; foreach (var id in shortStory.TagIds) { newStory.Tags.Add(this.tags.GetById(id)); } this.stories.Add(newStory); var viewModel = this.Mapper.Map<ShortStoryDetailsViewModel>(newStory); return this.RedirectToAction("Details", "ShortStories", new { id = viewModel.Id, area = "ShortStory" }); }
public ActionResult CreateStory(string id) { if (id == null) { this.Response.StatusCode = 404; return(this.Content("User was not found")); } var viewModel = new ShortStoryInputViewModel() { AuthorId = id, Tags = this.tags.GetAll().To <TagViewModel>() }; return(this.View(viewModel)); }
public ActionResult CreateStory(string id) { if (id == null) { this.Response.StatusCode = 404; return this.Content("User was not found"); } var viewModel = new ShortStoryInputViewModel() { AuthorId = id, Tags = this.tags.GetAll().To<TagViewModel>() }; return this.View(viewModel); }