Beispiel #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;
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the Posts EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToPosts(Post post)
 {
     base.AddObject("Posts", post);
 }
 /// <summary>
 /// Create a new Post object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="code">Initial value of the Code property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="estimatedSalary">Initial value of the EstimatedSalary property.</param>
 public static Post CreatePost(global::System.Int32 id, global::System.String code, global::System.String name, global::System.Decimal estimatedSalary)
 {
     Post post = new Post();
     post.Id = id;
     post.Code = code;
     post.Name = name;
     post.EstimatedSalary = estimatedSalary;
     return post;
 }