コード例 #1
0
        public async Task <IActionResult> Add(AddToDoInputModel input)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.View(input));
            }

            var userId = await this.usersService.GetUserIdAsync(this.User);

            input.UserId = userId;

            await this.toDoService.AddTodo(input);

            return(this.RedirectToAction("All", "Todo"));
        }
コード例 #2
0
        public async Task <bool> AddTodo(AddToDoInputModel model)
        {
            var result = new ToDo()
            {
                Description = model.Description,
                AlertOn     = model.AlertOn,
                CreatedOn   = DateTime.Now,
                IsActive    = true,
                UserId      = model.UserId,
            };

            await this.db.AddAsync(result);

            await this.db.SaveChangesAsync();

            return(true);
        }