public async Task <IActionResult> Delete(Guid id) { var todo = await _context.Todos.Where(TodoSpecifications.ById(id).Expression).FirstOrDefaultAsync(); if (todo == null) { return(WhenTodoNull(id)); } todo.MarkAs(TodoStatus.Abandoned); await _context.SaveChangesAsync(); return(NoContent()); }
public async Task <IActionResult> Get(Guid id) { var todo = await _context.Todos.Where(TodoSpecifications.ById(id).Expression).FirstOrDefaultAsync(); if (todo == null) { return(WhenTodoNull(id)); } return(Ok(new { todo })); }
public async Task <IActionResult> Put(Guid id, [FromBody] TodoBag value) { var todo = await _context.Todos.Where(TodoSpecifications.ById(id).Expression).FirstOrDefaultAsync(); if (todo == null) { return(WhenTodoNull(id)); } todo.UpdateFrom(value); await _context.SaveChangesAsync(); return(AcceptedAtAction("Get", new { id = todo.Id }, todo)); }
public async Task <IQueryable <Todo_Master> > ListAsync(short[] statuses = null, string searchString = null) { var spec = Spec.Any <Todo_Master>(); if (statuses?.Length > 0) { spec &= TodoSpecifications.ByStatusIDs(statuses); } if (!string.IsNullOrWhiteSpace(searchString)) { spec &= TodoSpecifications.BySearchString(searchString); } var query = _repository.GetBySpecification(spec); return(await Task.FromResult(query)); }