#region License Information /* HeuristicLab * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL) * * This file is part of HeuristicLab. * * HeuristicLab is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * HeuristicLab is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with HeuristicLab. If not, see . */ #endregion using System; using System.Collections.Generic; using System.Linq; using HeuristicLab.Hive.Contracts.BusinessObjects; using HeuristicLab.Hive.Server.DataAccess; namespace HeuristicLab.Hive.Server.LINQDataAccess { public class SlaveConfigDao: BaseDao, ISlaveConfigDao { #region IGenericDao Members public SlaveConfigDto FindById(Guid id) { return (from cc in Context.SlaveConfigs where cc.SlaveConfigId.Equals(id) select EntityToDto(cc, null)).SingleOrDefault(); } public IEnumerable FindAll() { return (from cc in Context.SlaveConfigs select EntityToDto(cc, null)).ToList(); } public SlaveConfigDto Insert(SlaveConfigDto bObj) { SlaveConfig c = DtoToEntity(bObj, null); Context.SlaveConfigs.InsertOnSubmit(c); CommitChanges(); bObj.Id = c.SlaveConfigId; return bObj; } public void Delete(Guid id) { Context.SlaveConfigs.DeleteOnSubmit(Context.SlaveConfigs.SingleOrDefault(c => c.SlaveConfigId.Equals(id))); CommitChanges(); } public void Update(SlaveConfigDto bObj) { SlaveConfig cc = Context.SlaveConfigs.SingleOrDefault(c => c.SlaveConfigId.Equals(bObj.Id)); DtoToEntity(bObj, cc); CommitChanges(); } #endregion public override SlaveConfig DtoToEntity(SlaveConfigDto source, SlaveConfig target) { if (source == null) return null; if (target == null) target = new SlaveConfig(); target.SlaveConfigId = source.Id; target.HeartBeatIntervall = source.HeartBeatIntervall; return target; } public override SlaveConfigDto EntityToDto(SlaveConfig source, SlaveConfigDto target) { if (source == null) return null; if (target == null) target = new SlaveConfigDto(); target.Id = source.SlaveConfigId; target.HeartBeatIntervall = source.HeartBeatIntervall; return target; } } }