Example #1
0
 public Blog Get(int id = -1)
 {
     if (id == -1)
         return null;
     else
         using (var context = new YHW.Models.SocialContext())
         {
             return context.BlogPost.Where(b => b.ID == id).FirstOrDefault();
         }
 }
Example #2
0
        public void Post(Blog b)
        {
            if (b == null)
                return;

            using (var context = new YHW.Models.SocialContext())
            {
                try
                {
                    context.BlogPost.Add(b);
                    context.SaveChanges();
                }
                catch(Exception e)
                {
                    // Dive on error
                    Console.WriteLine(e.Message);
                }
            }
        }