MCPcopy Create free account
hub / github.com/bbachi/react-dotnet-example / UserRepository

Class UserRepository

Models/UserRepository.cs:6–33  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4namespace react_dotnet_example.Models
5{
6 public class UserRepository: IUserRepository
7 {
8 private List<UserModel> users = new List<UserModel>();
9 private int _nextId = 1;
10
11 public UserRepository()
12 {
13 Add(new UserModel { firstName= "first1", lastName="last1", email="email1@gmail.com"});
14 Add(new UserModel { firstName= "first2", lastName="last2", email="email2@gmail.com"});
15 Add(new UserModel { firstName= "first3", lastName="last3", email="email3@gmail.com"});
16 }
17
18 public IEnumerable<UserModel> GetAll()
19 {
20 return users;
21 }
22
23 public UserModel Add(UserModel item)
24 {
25 if (item == null)
26 {
27 throw new ArgumentNullException("item");
28 }
29 item.Id = _nextId++;
30 users.Add(item);
31 return item;
32 }
33 }
34}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected