public ActionResult Create(CreateIdeaViewDto idea) { if (!ModelState.IsValid) { return(View(idea)); } _ideaService.AddCreatedPost(idea); return(RedirectToAction(DefaultActions.Index)); }
public void AddCreatedPost(CreateIdeaViewDto idea) { var authorId = _identityFacade.GetUserId(); var user = _userRepo.Find(authorId); var dbPost = Mapper.Map <Idea>(idea); dbPost.Author = user; dbPost.CreatedOn = DateTime.Now; _ideaRepo.Add(dbPost); }
public ActionResult Edit(CreateIdeaViewDto idea) { if (ModelState.IsValid) { _ideaService.UpdatePost(idea); return(RedirectToAction(DefaultActions.Index)); } idea = _ideaService.CreatePostModel(); return(View(idea)); }
public void UpdatePost(CreateIdeaViewDto idea) { var dbPost = Mapper.Map <Idea>(idea); _ideaRepo.Update(dbPost); }
public CreateIdeaViewDto CreatePostModel() { var createPostModel = new CreateIdeaViewDto(); return(createPostModel); }