Inheritance: System.Data.Objects.DataClasses.EntityObject
Ejemplo n.º 1
0
        public bool AddPost(Post post, string subforum)
        {
            //Getting last id:
            IEnumerable<int> postKeysList = (from m in ForumContext.PostKeyEntities
                                             select m.PostKeyId);
            int lastId = 0;
            if (postKeysList.Count() != 0)
            {
                lastId = postKeysList.Max();
            }
            currentPostKeyId = lastId + 1;

            PostKeyEntity pke = new PostKeyEntity();
            pke.PostKeyId = currentPostKeyId;
            pke.Username = post.Key.Username;
            pke.Time = post.Key.Time;

            PostEntity pe = new PostEntity();
            pe.PostKeyId = currentPostKeyId;
            pe.ParentPostKeyId = -1;
            pe.Title = post.Title;
            pe.Body = post.Body;
            pe.SubforumName = subforum; //TODO - Why do we need 'subforum'?
            try
            {
                ForumContext.AddToPostKeyEntities(pke);
                ForumContext.AddToPostEntities(pe);
                ForumContext.SaveChanges();
                return true;
            }
            catch (Exception)
            {
                //TODO
                throw;
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Create a new PostKeyEntity object.
 /// </summary>
 /// <param name="postKeyId">Initial value of the PostKeyId property.</param>
 /// <param name="username">Initial value of the Username property.</param>
 /// <param name="time">Initial value of the Time property.</param>
 public static PostKeyEntity CreatePostKeyEntity(global::System.Int32 postKeyId, global::System.String username, global::System.DateTime time)
 {
     PostKeyEntity postKeyEntity = new PostKeyEntity();
     postKeyEntity.PostKeyId = postKeyId;
     postKeyEntity.Username = username;
     postKeyEntity.Time = time;
     return postKeyEntity;
 }
Ejemplo n.º 3
0
        public bool AddReply(Post reply, Postkey postKey)
        {
            try
            {
                // Find parent postkey:
                IEnumerable<PostKeyEntity> postkeyQuery = GetPostKeyEntity(postKey);
                IEnumerable<PostEntity> postQuery = GetPostEntity(postKey);

                //Getting last id:
                IEnumerable<int> postKeysList = (from m in ForumContext.PostKeyEntities
                                                 select m.PostKeyId);
                int lastId = 0;
                if (postKeysList.Count() != 0)
                {
                    lastId = postKeysList.Max();
                }
                currentPostKeyId = lastId + 1;

                PostKeyEntity pke = new PostKeyEntity();
                pke.PostKeyId = currentPostKeyId;
                pke.Username = reply.Key.Username;
                pke.Time = reply.Key.Time;
                ForumContext.AddToPostKeyEntities(pke);
                PostEntity pe = new PostEntity();

                pe.PostKeyId = currentPostKeyId;
                //currentPostKeyId++;
                pe.ParentPostKeyId = postkeyQuery.ElementAt(0).PostKeyId;
                pe.Title = reply.Title;
                pe.Body = reply.Body;
                pe.SubforumName = postQuery.ElementAt(0).SubforumName;

                ForumContext.AddToPostEntities(pe);
                ForumContext.SaveChanges();
                return true;
            }
            catch (Exception)
            {
                //TODO
                throw;
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Deprecated Method for adding a new object to the PostKeyEntities EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToPostKeyEntities(PostKeyEntity postKeyEntity)
 {
     base.AddObject("PostKeyEntities", postKeyEntity);
 }