Ejemplo n.º 1
0
        public async Task <IActionResult> Create([FromBody] TodoItem model)
        {
            if (string.IsNullOrEmpty(model.Description))
            {
                return(BadRequest());
            }
            model.DateTimeCreated = DateTime.Now;
            var result = await _context.TodoItems.AddAsync(model).ConfigureAwait(false);

            await _context.SaveChangesAsync().ConfigureAwait(false);

            return(Ok(result));
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> CreateTaskListAsync([FromBody] CreateTaskListRequest request)
        {
            if (string.IsNullOrEmpty(request.Title))
            {
                return(BadRequest("Title must not be empty."));
            }

            var taskList = new TaskList(request.Title);

            await dbContext.TaskLists.AddAsync(taskList);

            var createdId = await dbContext.SaveChangesAsync();

            return(CreatedAtRoute(nameof(GetTaskListByIdAsync), new { id = createdId }, null));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> DeleteAccountAsync()
        {
            var accountId = User.ReadClaimAsGuidValue("urn:codefliptodo:accountid");

            var deleteAccount = new DeleteAccount
            {
                AccountId = accountId
            };

            await _mediator.Send(deleteAccount);

            await _todoDatabaseContext.SaveChangesAsync();

            return(Ok("account deleted!"));
        }
 public async Task <int> SaveChangesAsync(CancellationToken cancellationToken = default)
 {
     return(await _context.SaveChangesAsync());
 }
Ejemplo n.º 5
0
 public Task <int> SaveChangesAsync(CancellationToken cancellationToken = default)
 {
     return(_context.SaveChangesAsync(cancellationToken));
 }