コード例 #1
0
        public void NoteData(DbContextOptions <TodoApiContext> options)
        {
            using (var todocontext = new TodoApiContext(options))
            {
                var note = new List <Note>()
                {
                    new Note()
                    {
                        ID         = 1,
                        Title      = "Boeing",
                        PlainText  = "Aerospace company",
                        Pinned     = false,
                        CheckLists = new List <CheckList>()
                        {
                            new CheckList()
                            {
                                CheckListData = "Jumbo Jet",
                                Status        = true
                            }
                        },
                        Labels = new List <Label>()
                        {
                            new Label()
                            {
                                LabelData = "Dreamliner"
                            }
                        }
                    },

                    new Note()
                    {
                        ID         = 3,
                        Title      = "Boeings",
                        PlainText  = "Aerospace companys",
                        Pinned     = false,
                        CheckLists = new List <CheckList>()
                        {
                            new CheckList()
                            {
                                CheckListData = "Jumbo Jets",
                                Status        = true
                            }
                        },
                        Labels = new List <Label>()
                        {
                            new Label()
                            {
                                LabelData = "Dreamliners"
                            }
                        }
                    }
                };
                todocontext.Note.AddRange(note);
                todocontext.SaveChanges();
            }
        }
コード例 #2
0
ファイル: TodoController.cs プロジェクト: Ciclo-DAW/DWES
 public TodoController(TodoApiContext context)
 {
     _context = context;
     if (_context.Tareas.Count() == 0)
     {
         // Create a new TodoItem if collection is empty,
         _context.Tareas.Add(new Tarea {
             Descripcion = "Item1"
         });
         _context.SaveChanges();
     }
 }
コード例 #3
0
        public TodoController(TodoApiContext context)
        {
            _context = context;

            if (_context.TodoItems.Count() == 0)
            {
                _context.TodoItems.Add(new TodoItem {
                    Name = "Item1"
                });
                _context.SaveChanges();
            }
        }
コード例 #4
0
ファイル: TodoModule.cs プロジェクト: BruceBC/BakeOffNancy
        private Todo create(object args)
        {
            Todo todo = this.Bind();

            var connection = @"Server=localhost;Port=5432;User ID=postgres;Password=postgres;Database=nancy;";
            var options    = new DbContextOptionsBuilder <TodoApiContext>();

            options.UseNpgsql(connection);

            using (var context = new TodoApiContext(options.Options))
            {
                context.Add <Todo>(todo);
                context.SaveChanges();
            }

            return(todo);
        }
コード例 #5
0
        public IHttpActionResult PostTodo(Todo todo)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var principal = User as ClaimsPrincipal;

            var owner = (from c in principal.Claims
                         where c.Type == "hovland.name/Display name"
                         select c.Value).FirstOrDefault();

            todo.Owner = owner;
            db.Todos.Add(todo);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = todo.TodoId }, todo));
        }
コード例 #6
0
 public bool Add(TEntity obj)
 {
     _db.Set <TEntity>().Add(obj);
     return(_db.SaveChanges() > 0);
 }
コード例 #7
0
ファイル: TodoController.cs プロジェクト: Ciclo-DAW/DWES
 public ActionResult <Tarea> PostTodoItem(Tarea item)
 {
     _context.Tareas.Add(item);
     _context.SaveChanges();
     return(CreatedAtAction(nameof(GetTodoItem), new { id = item.Id }, item));
 }