public void Update(EPostDTO post) { var postEntity = _postRepository.Find(post.Id); AutoMapper.Mapper.DynamicMap(post, postEntity); _postRepository.Update(postEntity); }
public void Insert(EPostDTO post) { var postEntity = AutoMapper.Mapper.DynamicMap <Post>(post); postEntity.CreatedOn = DateTime.Now; _postRepository.Insert(postEntity); }
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)); }
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)); } }