Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
 public async Task<ReturnSet<bool>> CreatePost(PostCreationRequestItem requestItem) => await PUT<PostCreationRequestItem, ReturnSet<bool>>(requestItem);        
Exemplo n.º 3
0
 public ReturnSet<bool> PUT(PostCreationRequestItem requestItem) => new PostManager(APIWrapper).AddPost(requestItem);