Example #1
0
        public void Update(EPostDTO post)
        {
            var postEntity = _postRepository.Find(post.Id);

            AutoMapper.Mapper.DynamicMap(post, postEntity);
            _postRepository.Update(postEntity);
        }
Example #2
0
        public void Insert(EPostDTO post)
        {
            var postEntity = AutoMapper.Mapper.DynamicMap <Post>(post);

            postEntity.CreatedOn = DateTime.Now;
            _postRepository.Insert(postEntity);
        }
Example #3
0
 public ActionResult Update(EPostDTO post)
 {
     post.Slug        = _postService.GetSlugAnyPost(StringManager.ToSlug(post.Title));
     post.UserId      = ((SessionContext)Session["SessionContext"]).Id;
     post.PostContent = HttpUtility.HtmlEncode(post.PostContent);
     if (Session["TempImage"] != null)
     {
         post.Image = (byte[])Session["TempImage"];
     }
     _postService.Update(post);
     _uow.SaveChanges();
     return(Json(true, JsonRequestBehavior.AllowGet));
 }
Example #4
0
 public ActionResult Insert(EPostDTO post)
 {
     try
     {
         // _uow.BeginTransaction();
         post.Slug        = _postService.GetSlugAnyPost(StringManager.ToSlug(post.Title));
         post.UserId      = ((SessionContext)Session["SessionContext"]).Id;
         post.PostContent = HttpUtility.HtmlEncode(post.PostContent);
         if (Session["TempImage"] != null)
         {
             post.Image = (byte[])Session["TempImage"];
         }
         _postService.Insert(post);
         _uow.SaveChanges();
         // _uow.Commit();
         return(Json(true, JsonRequestBehavior.AllowGet));
     }
     catch (Exception)
     {
         _uow.Rollback();
         return(Json(false, JsonRequestBehavior.AllowGet));
     }
 }