Beispiel #1
0
 public void DeleteMarkedPost(MarkedPost post)
 {
     using (var contex = new StackOverflowContext())
     {
         contex.MarkedPost.Remove(post);
         contex.SaveChanges();
     }
 }
Beispiel #2
0
        public void CreateMarkedPost(MarkedPost post)
        {
            using (var contex = new StackOverflowContext())
            {
                contex.MarkedPost.Add(post);
                contex.SaveChanges();
                //var nextId = contex.Categories.Max(x => x.Id) + 1;
                //category.Id = nextId;
                // Instead of this change the database to use auto increment on
                // the categoryid in the category table.
                // Note: that you need to remove the foreign key in product first,
                // then add the AI and finally reenter the FK on product.

                //contex.Categories.Add(category);
                //contex.SaveChanges();
            }
        }