[3011] | 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 | #region IGenericDao<ClientConfigDto,ClientConfig> Members
|
---|
| 12 |
|
---|
| 13 | public ClientConfigDto FindById(Guid id) {
|
---|
| 14 | return (from cc in Context.ClientConfigs
|
---|
| 15 | where cc.ClientConfigId.Equals(id)
|
---|
| 16 | select EntityToDto(cc, null)).SingleOrDefault();
|
---|
| 17 | }
|
---|
| 18 |
|
---|
| 19 | public IEnumerable<ClientConfigDto> FindAll() {
|
---|
| 20 | return (from cc in Context.ClientConfigs
|
---|
| 21 | select EntityToDto(cc, null)).ToList();
|
---|
| 22 | }
|
---|
| 23 |
|
---|
| 24 | public ClientConfigDto Insert(ClientConfigDto bObj) {
|
---|
| 25 | ClientConfig c = DtoToEntity(bObj, null);
|
---|
| 26 | Context.ClientConfigs.InsertOnSubmit(c);
|
---|
[3578] | 27 | CommitChanges();
|
---|
[3011] | 28 | bObj.Id = c.ClientConfigId;
|
---|
| 29 | return bObj;
|
---|
| 30 | }
|
---|
| 31 |
|
---|
| 32 | public void Delete(ClientConfigDto bObj) {
|
---|
| 33 | Context.ClientConfigs.DeleteOnSubmit(Context.ClientConfigs.SingleOrDefault(c => c.ClientConfigId.Equals(bObj.Id)));
|
---|
[3578] | 34 | CommitChanges();
|
---|
[3011] | 35 | }
|
---|
| 36 |
|
---|
| 37 | public void Update(ClientConfigDto bObj) {
|
---|
| 38 | ClientConfig cc = Context.ClientConfigs.SingleOrDefault(c => c.ClientConfigId.Equals(bObj.Id));
|
---|
| 39 | DtoToEntity(bObj, cc);
|
---|
[3578] | 40 | CommitChanges();
|
---|
[3011] | 41 | }
|
---|
| 42 |
|
---|
| 43 | #endregion
|
---|
| 44 |
|
---|
| 45 | public override ClientConfig DtoToEntity(ClientConfigDto source, ClientConfig target) {
|
---|
| 46 | if (source == null)
|
---|
| 47 | return null;
|
---|
| 48 | if (target == null)
|
---|
| 49 | target = new ClientConfig();
|
---|
| 50 |
|
---|
| 51 | target.ClientConfigId = source.Id;
|
---|
| 52 | target.HeartBeatIntervall = source.HeartBeatIntervall;
|
---|
| 53 |
|
---|
| 54 | return target;
|
---|
| 55 | }
|
---|
| 56 |
|
---|
| 57 | public override ClientConfigDto EntityToDto(ClientConfig source, ClientConfigDto target) {
|
---|
| 58 | if (source == null)
|
---|
| 59 | return null;
|
---|
| 60 | if (target == null)
|
---|
| 61 | target = new ClientConfigDto();
|
---|
| 62 |
|
---|
| 63 | target.Id = source.ClientConfigId;
|
---|
| 64 | target.HeartBeatIntervall = source.HeartBeatIntervall;
|
---|
| 65 |
|
---|
| 66 | return target;
|
---|
| 67 |
|
---|
| 68 | }
|
---|
| 69 | }
|
---|
| 70 | }
|
---|