region UserCard public UserCardDTO GetUserCard int id var userCard map

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#region UserCard
public UserCardDTO GetUserCard(int id) {
var userCard = mapper.Map<UserCard, UserCardDTO>(unitOfWork.UserCards
.GetSingle(x => x.Id == id));
return userCard ?? throw new UserCardNotFoundException();
}
public UserCardDTO GetUserCard(string firstName, string lastName) {
var userCard = mapper.Map<UserCard, UserCardDTO>(unitOfWork.UserCards.GetSingle(x =>
firstName == null ? true : x.FirstName == firstName &&
lastName == null ? true : x.LastName == lastName
));
return userCard ?? throw new UserCardNotFoundException();
}
public UserCardDTO GetUserCard(int? id, string firstName, string lastName) {
var userCard = mapper.Map<UserCard, UserCardDTO>(unitOfWork.UserCards.GetSingle(x =>
id == null ? true : x.Id == id &&
firstName == null ? true : x.FirstName == firstName &&
lastName == null ? true : x.LastName == lastName
));
return userCard ?? throw new UserCardNotFoundException();
}
public IEnumerable<UserCardDTO> GetUserCards() {
var userCards = mapper.Map<IEnumerable<UserCard>, IList<UserCardDTO>>(unitOfWork
.UserCards.GetAll());
return userCards.Count != 0 ? userCards : throw new UserCardNotFoundException();
}
public IEnumerable<UserCardDTO> GetUserCards(int? id, string firstName, string lastName) {
var userCards = mapper.Map<IEnumerable<UserCard>, IList<UserCardDTO>>(unitOfWork.UserCards.FindBy(x =>
id == null ? true : x.Id == id &&
firstName == null ? true : x.FirstName == firstName &&
lastName == null ? true : x.LastName == lastName
));
return userCards.Count != 0 ? userCards : throw new UserCardNotFoundException();
}
#endregion