예제 #1
0
        public PostResponse SavePost(PostRequest request)
        {
            var response = new PostResponse();

            if (request.Post != null)
            {
                Post post;

                // Check if Edit or Add
                if (request.Post.Id > 0)
                {   // Edit
                    post = Olympus._Enterprise.Posts.Where(x => x.Id == request.Post.Id).SingleOrDefault();
                    Mapper.Map(request.Post, post);
                }
                else
                {   // Add
                    post = new Post();
                    Mapper.Map(request.Post, post);
                    Olympus._Enterprise.Posts.AddObject(post);
                }
                Olympus._Enterprise.SaveChanges();
                if (post != null) response.PostId = post.Id;
            }
            return response;
        }
예제 #2
0
 public PostResponse GetPost(PostRequest request)
 {
     var response = new PostResponse();
     if (request.PostId > 0)
     {
         var postFound = Olympus._Enterprise.Posts.Where(x => x.Id == request.PostId).SingleOrDefault();
         if (postFound != null)
         {
             response.Post = Mapper.Map<PostDto>(postFound);
         }
     }
     return response;
 }
예제 #3
0
        public PostResponse SearchPost(PostRequest request)
        {
            var response = new PostResponse {PostList = new List<PostDto>()};

            var postFound = Olympus._Enterprise.Posts.ToList();

            //if (postFound != null)
            if (postFound.Count > 0)
            {
                foreach (var post in postFound)
                {
                    Olympus._Enterprise.Detach(post);
                    var tmpPost = Mapper.Map<PostDto>(post);
                    response.PostList.Add(tmpPost);
                }
            }
            return response;
        }
예제 #4
0
 private void Search(string query)
 {
     var request = new PostRequest { SearchPostQuery = query };
     ShowSearchResults(new PostFactory().SearchPost(request).PostList);
 }
예제 #5
0
 // Search
 public PostResponse SearchPost(PostRequest request)
 {
     return _postService.SearchPost(request);
 }
예제 #6
0
 // Save
 public PostResponse SavePost(PostRequest request)
 {
     return _postService.SavePost(request);
 }
예제 #7
0
 // Get
 public PostResponse GetPost(PostRequest request)
 {
     return _postService.GetPost(request);
 }