コード例 #1
0
 public static void UpdatePostIt(Model.PostIt postIt)
 {
     using (PostItContext context = CreateContext())
     {
         context.PostIts.Update(postIt);
         context.SaveChanges();
     }
 }
コード例 #2
0
 public static void DeletePostIt(Model.PostIt postIt)
 {
     using (PostItContext context = CreateContext())
     {
         postIt.Category.PostIts.Remove(postIt);
         context.PostIts.Remove(postIt);
         context.SaveChanges();
     }
 }
コード例 #3
0
        public static void ChangePostItCategory(Model.PostIt model, Category category)
        {
            using (PostItContext context = CreateContext())
            {
                var postIt = context.PostIts.FirstOrDefault(p => p.Id == model.Id);

                int indexPostit = model.Category.PostIts.IndexOf(model);
                model.Category.PostIts.RemoveAt(indexPostit);

                var newCategory = context.Categories.FirstOrDefault(c => c.Id == category.Id);
                model.Category    = category;
                model.CategoryId  = category.Id;
                postIt.Category   = category;
                postIt.CategoryId = category.Id;
                context.PostIts.Update(postIt);
                category.PostIts.Add(model);
                context.SaveChanges();
            }
        }
コード例 #4
0
 public static void CreatePostIt(string text, Category category, Color color)
 {
     if (category == null)
     {
         throw new Exception("Please add a category");
     }
     using (PostItContext context = CreateContext())
     {
         Model.PostIt postIt = new Model.PostIt()
         {
             Text       = text,
             Category   = category,
             CategoryId = category.Id,
             ColorArgb  = color.ToArgb()
         };
         var dbCategory = context.Categories.Include(c => c.PostIts).First(c => c.Id == category.Id);
         dbCategory.PostIts.Add(postIt);
         context.SaveChanges();
         postIt.Category = category;
         category.PostIts.Add(postIt);
     }
 }
コード例 #5
0
 public PostItViewModel(Model.PostIt postIt)
 {
     Model = postIt;
     ElementAreFocused += PostItViewModel_ElementAreFocused;
 }