public async Task <ActionResult> Delete([FromRoute] Guid id) { var user = await database.GetById <UserModel>(id); if (user == null) { return(NotFound()); } var userLinks = await database.GetWhere <LinkModel>(l => l.Creator.Guid == id).ToArrayAsync(); foreach (var link in userLinks) { var accesses = await database.GetWhere <AccessModel>(a => a.Link.Guid == link.Guid).ToArrayAsync(); database.DeleteRange(accesses); } database.DeleteRange(userLinks); database.Delete(user); await database.Commit(); return(NoContent()); }
public async Task <ActionResult> Delete([FromRoute] Guid id) { var link = await database.GetById <LinkModel>(id); if (link == null) { return(NotFound()); } if (!Can(Permissions.DELETE_LINKS, link)) { return(NotFound()); } var accesses = await database.GetWhere <AccessModel>(a => a.Link.Guid == id).ToArrayAsync(); database.DeleteRange(accesses); database.Delete(link); await database.Commit(); await cache.Remove <LinkModel>(link.Ident); return(NoContent()); }