Example #1
0
 public ActionResult Create(CreateIdeaViewDto idea)
 {
     if (!ModelState.IsValid)
     {
         return(View(idea));
     }
     _ideaService.AddCreatedPost(idea);
     return(RedirectToAction(DefaultActions.Index));
 }
Example #2
0
        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);
        }
Example #3
0
        public ActionResult Edit(CreateIdeaViewDto idea)
        {
            if (ModelState.IsValid)
            {
                _ideaService.UpdatePost(idea);
                return(RedirectToAction(DefaultActions.Index));
            }

            idea = _ideaService.CreatePostModel();
            return(View(idea));
        }
Example #4
0
        public void UpdatePost(CreateIdeaViewDto idea)
        {
            var dbPost = Mapper.Map <Idea>(idea);

            _ideaRepo.Update(dbPost);
        }
Example #5
0
        public CreateIdeaViewDto CreatePostModel()
        {
            var createPostModel = new CreateIdeaViewDto();

            return(createPostModel);
        }