This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class OrderController : Controller { | |
// rest of code omitted | |
public IActionResult ById(string id){ | |
var order =_orders.Find(id); | |
return View(order); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class OrderController : Controller { | |
// rest of code omitted | |
public IActionResult ById(string id){ | |
var order = _orders.Find(id); | |
if(order == null){ | |
return NotFound(); | |
} | |
return Ok(order); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using Microsoft.AspNetCore.Mvc; | |
namespace UsersAPI.Controllers | |
{ | |
[Route("api/[controller]")] | |
[ApiController] | |
public class UserController : ControllerBase | |
{ | |
[HttpGet] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public componentDidMount() { | |
fetch('https://localhost:44348/api/user') | |
.then(res => res.json()) | |
.then(users => | |
this.setState({ users }) | |
); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public async componentDidMount() { | |
const result = await fetch('https://localhost:44348/api/user'); | |
const users = await result.json(); | |
this.setState({ users }); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public render() { | |
return ( | |
<div> | |
<h1>My Users</h1> | |
<table className="user-list"> | |
<tbody> | |
{this.state.users.map(user => | |
<UserRow key={user.id} user={user} />)} | |
</tbody> | |
</table> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default class MyUsers extends React.Component<any, any>{ | |
public state = { | |
"users": [ | |
{ "id": 1, "name": "Jon Hilton", "summary": "36 / Lead Developer" }, | |
{ "id": 2, "name": "Janine Smith", "summary": "32 / Senior Engineer" } | |
] | |
}; | |
// rest of class omitted |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private getUserData() { | |
// ajax call to get data | |
// return the data | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private getUserData() { | |
return [ | |
{ id: 1, name: 'Jon', summary: '36 / Lead Developer' }, | |
{ id: 2, name: 'Janine Smith', summary: '32 / Senior Engineer' } | |
]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public render() { | |
return ( | |
<div> | |
<h1>My Users</h1> | |
<table className="user-list"> | |
<tbody> | |
{this.getUserData().map(user => | |
<UserRow key={user.id} user={user} />)} | |
</tbody> | |
</table> |