Пример #1
0
        public void RemovePost(int postId)
        {
            try
            {
                using (var context = new ChatUp_DBEntities())
                {
                    var query = (from p in context.Post
                                 where p.Id == postId
                                 select p).FirstOrDefault();
                    if (query == null) throw new FaultException("Post not found");

                    context.Post.Remove(query);
                    context.SaveChanges();
                }
            }
            catch (Exception exception)
            {
                throw new FaultException(exception.Message);
            }
        }
Пример #2
0
 public void SubmitChat(Post post)
 {
     try
     {
         if (post == null) throw new Exception();
         using (var context = new ChatUp_DBEntities())
         {
             var newPost = new Post
             {
                 Submitter = post.Submitter,
                 ChatRoomId = post.ChatRoomId,
                 Comment = post.Comment,
                 TimeSubmitted = post.TimeSubmitted
             };
             context.Post.Add(newPost);
             context.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw new FaultException<Exception>(ex);
     }
 }