1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Linq;
|
---|
4 | using System.Text;
|
---|
5 | using HeuristicLab.Hive.Contracts.BusinessObjects;
|
---|
6 | using HeuristicLab.Hive.Server.DataAccess;
|
---|
7 |
|
---|
8 | namespace HeuristicLab.Hive.Server.LINQDataAccess {
|
---|
9 | public class ClientConfigDao: BaseDao<ClientConfigDto, ClientConfig>, IClientConfigDao {
|
---|
10 |
|
---|
11 |
|
---|
12 | #region IGenericDao<ClientConfigDto,ClientConfig> Members
|
---|
13 |
|
---|
14 | public ClientConfigDto FindById(Guid id) {
|
---|
15 | return (from cc in Context.ClientConfigs
|
---|
16 | where cc.ClientConfigId.Equals(id)
|
---|
17 | select EntityToDto(cc, null)).SingleOrDefault();
|
---|
18 | }
|
---|
19 |
|
---|
20 | public IEnumerable<ClientConfigDto> FindAll() {
|
---|
21 | return (from cc in Context.ClientConfigs
|
---|
22 | select EntityToDto(cc, null)).ToList();
|
---|
23 | }
|
---|
24 |
|
---|
25 | public ClientConfigDto Insert(ClientConfigDto bObj) {
|
---|
26 | ClientConfig c = DtoToEntity(bObj, null);
|
---|
27 | Context.ClientConfigs.InsertOnSubmit(c);
|
---|
28 | Context.SubmitChanges();
|
---|
29 | bObj.Id = c.ClientConfigId;
|
---|
30 | return bObj;
|
---|
31 | }
|
---|
32 |
|
---|
33 | public void Delete(ClientConfigDto bObj) {
|
---|
34 | Context.ClientConfigs.DeleteOnSubmit(Context.ClientConfigs.SingleOrDefault(c => c.ClientConfigId.Equals(bObj.Id)));
|
---|
35 | Context.SubmitChanges();
|
---|
36 | }
|
---|
37 |
|
---|
38 | public void Update(ClientConfigDto bObj) {
|
---|
39 | ClientConfig cc = Context.ClientConfigs.SingleOrDefault(c => c.ClientConfigId.Equals(bObj.Id));
|
---|
40 | DtoToEntity(bObj, cc);
|
---|
41 | Context.SubmitChanges();
|
---|
42 | }
|
---|
43 |
|
---|
44 | #endregion
|
---|
45 |
|
---|
46 | public override ClientConfig DtoToEntity(ClientConfigDto source, ClientConfig target) {
|
---|
47 | if (source == null)
|
---|
48 | return null;
|
---|
49 | if (target == null)
|
---|
50 | target = new ClientConfig();
|
---|
51 |
|
---|
52 | target.ClientConfigId = source.Id;
|
---|
53 | target.HeartBeatIntervall = source.HeartBeatIntervall;
|
---|
54 |
|
---|
55 | return target;
|
---|
56 | }
|
---|
57 |
|
---|
58 | public override ClientConfigDto EntityToDto(ClientConfig source, ClientConfigDto target) {
|
---|
59 | if (source == null)
|
---|
60 | return null;
|
---|
61 | if (target == null)
|
---|
62 | target = new ClientConfigDto();
|
---|
63 |
|
---|
64 | target.Id = source.ClientConfigId;
|
---|
65 | target.HeartBeatIntervall = source.HeartBeatIntervall;
|
---|
66 |
|
---|
67 | return target;
|
---|
68 |
|
---|
69 | }
|
---|
70 | }
|
---|
71 | }
|
---|