public ReturnSet <bool> AddPost(PostCreationRequestItem requestItem) { using (var eFactory = new EFModel()) { var post = eFactory.Posts.Create(); post.Active = true; post.Created = DateTime.Now; post.Modified = DateTime.Now; post.Body = requestItem.Body; post.Summary = requestItem.Body.Length > 255 ? requestItem.Body.Substring(0, 252) + "..." : requestItem.Body; post.Title = requestItem.Title; post.SafeURL = requestItem.Title.Replace(" ", "-"); eFactory.Posts.Add(post); eFactory.SaveChanges(); var key = eFactory.DGTPostKeys.Create(); key.PostID = post.ID; key.PostKey = $"{post.Created.Year}_{post.Created.Month}_{post.Created.Day}_{post.SafeURL}"; eFactory.DGTPostKeys.Add(key); eFactory.SaveChanges(); return(new ReturnSet <bool>(true)); } }
public async Task <ReturnSet <bool> > CreatePost(PostCreationRequestItem requestItem) => await PUT <PostCreationRequestItem, ReturnSet <bool> >(requestItem);
public ReturnSet <bool> PUT(PostCreationRequestItem requestItem) => new PostManager(APIWrapper).AddPost(requestItem);