1 | #region License Information
|
---|
2 | /* HeuristicLab
|
---|
3 | * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
4 | *
|
---|
5 | * This file is part of HeuristicLab.
|
---|
6 | *
|
---|
7 | * HeuristicLab is free software: you can redistribute it and/or modify
|
---|
8 | * it under the terms of the GNU General Public License as published by
|
---|
9 | * the Free Software Foundation, either version 3 of the License, or
|
---|
10 | * (at your option) any later version.
|
---|
11 | *
|
---|
12 | * HeuristicLab is distributed in the hope that it will be useful,
|
---|
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
15 | * GNU General Public License for more details.
|
---|
16 | *
|
---|
17 | * You should have received a copy of the GNU General Public License
|
---|
18 | * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
|
---|
19 | */
|
---|
20 | #endregion
|
---|
21 |
|
---|
22 | using System;
|
---|
23 | using System.Collections.Generic;
|
---|
24 | using System.Linq;
|
---|
25 | using HeuristicLab.Hive.Contracts.BusinessObjects;
|
---|
26 | using HeuristicLab.Hive.Server.DataAccess;
|
---|
27 |
|
---|
28 | namespace HeuristicLab.Hive.Server.LINQDataAccess {
|
---|
29 | public class SlaveConfigDao: BaseDao<SlaveConfigDto, SlaveConfig>, ISlaveConfigDao {
|
---|
30 |
|
---|
31 | #region IGenericDao<SlaveConfigDto,SlaveConfig> Members
|
---|
32 |
|
---|
33 | public SlaveConfigDto FindById(Guid id) {
|
---|
34 | return (from cc in Context.SlaveConfigs
|
---|
35 | where cc.SlaveConfigId.Equals(id)
|
---|
36 | select EntityToDto(cc, null)).SingleOrDefault();
|
---|
37 | }
|
---|
38 |
|
---|
39 | public IEnumerable<SlaveConfigDto> FindAll() {
|
---|
40 | return (from cc in Context.SlaveConfigs
|
---|
41 | select EntityToDto(cc, null)).ToList();
|
---|
42 | }
|
---|
43 |
|
---|
44 | public SlaveConfigDto Insert(SlaveConfigDto bObj) {
|
---|
45 | SlaveConfig c = DtoToEntity(bObj, null);
|
---|
46 | Context.SlaveConfigs.InsertOnSubmit(c);
|
---|
47 | CommitChanges();
|
---|
48 | bObj.Id = c.SlaveConfigId;
|
---|
49 | return bObj;
|
---|
50 | }
|
---|
51 |
|
---|
52 | public void Delete(Guid id) {
|
---|
53 | Context.SlaveConfigs.DeleteOnSubmit(Context.SlaveConfigs.SingleOrDefault(c => c.SlaveConfigId.Equals(id)));
|
---|
54 | CommitChanges();
|
---|
55 | }
|
---|
56 |
|
---|
57 | public void Update(SlaveConfigDto bObj) {
|
---|
58 | SlaveConfig cc = Context.SlaveConfigs.SingleOrDefault(c => c.SlaveConfigId.Equals(bObj.Id));
|
---|
59 | DtoToEntity(bObj, cc);
|
---|
60 | CommitChanges();
|
---|
61 | }
|
---|
62 |
|
---|
63 | #endregion
|
---|
64 |
|
---|
65 | public override SlaveConfig DtoToEntity(SlaveConfigDto source, SlaveConfig target) {
|
---|
66 | if (source == null)
|
---|
67 | return null;
|
---|
68 | if (target == null)
|
---|
69 | target = new SlaveConfig();
|
---|
70 |
|
---|
71 | target.SlaveConfigId = source.Id;
|
---|
72 | target.HeartBeatIntervall = source.HeartBeatIntervall;
|
---|
73 |
|
---|
74 | return target;
|
---|
75 | }
|
---|
76 |
|
---|
77 | public override SlaveConfigDto EntityToDto(SlaveConfig source, SlaveConfigDto target) {
|
---|
78 | if (source == null)
|
---|
79 | return null;
|
---|
80 | if (target == null)
|
---|
81 | target = new SlaveConfigDto();
|
---|
82 |
|
---|
83 | target.Id = source.SlaveConfigId;
|
---|
84 | target.HeartBeatIntervall = source.HeartBeatIntervall;
|
---|
85 |
|
---|
86 | return target;
|
---|
87 |
|
---|
88 | }
|
---|
89 | }
|
---|
90 | }
|
---|