示例#1
0
        public async Task <IActionResult> Create([Bind("Id,Title,Content")] Todo todo)
        {
            if (ModelState.IsValid)
            {
                _context.Add(todo);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(todo));
        }
示例#2
0
        public async Task <Board> AddBoard(Board board)
        {
            var newBoard = new Board
            {
                Name        = board.Name,
                Description = board.Description,
                CreatorId   = board.CreatorId
            };

            _db.Add(newBoard);

            await _db.SaveChangesAsync();

            return(newBoard);
        }
示例#3
0
        public async Task <Record> AddRecord(RecordDTO record, int boardId)
        {
            var newRecord = new Record
            {
                Name         = record.Name,
                Description  = record.Description,
                BoardId      = boardId,
                CreationDate = DateTimeOffset.Now,
                EndDate      = record.EndDate, // "0001-01-01T00:00:00+00:00" returns
                CreatorId    = 1               // fix to current user id
            };

            _db.Add(newRecord);

            await _db.SaveChangesAsync();

            return(newRecord);
        }