Changeset 4426 for trunk/sources
- Timestamp:
- 09/18/10 04:03:28 (14 years ago)
- Location:
- trunk/sources/HeuristicLab.Services.OKB/3.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Services.OKB/3.3/AdminService.cs
r4407 r4426 20 20 #endregion 21 21 22 using System.Collections.Generic; 22 23 using System.Data.Linq; 23 24 using System.Linq; … … 31 32 [ServiceBehavior(IncludeExceptionDetailInFaults = true)] 32 33 public class AdminService : IAdminService { 33 public void AddAlgorithmClass(AlgorithmClass algorithmClass) { 34 using (OKBDataContext okb = new OKBDataContext()) { 35 okb.AlgorithmClasses.InsertOnSubmit(new AlgorithmClass() { 36 Name = algorithmClass.Name, 37 Description = algorithmClass.Description 38 }); 39 okb.SubmitChanges(); 40 } 41 } 42 public AlgorithmClass[] GetAlgorithmClasses() { 34 public AlgorithmClass GetAlgorithmClass(long algorithmClassId) { 35 using (OKBDataContext okb = new OKBDataContext()) { 36 return okb.AlgorithmClasses.FirstOrDefault(a => a.Id == algorithmClassId); 37 } 38 } 39 public IEnumerable<AlgorithmClass> GetAlgorithmClasses() { 43 40 using (OKBDataContext okb = new OKBDataContext()) { 44 41 return okb.AlgorithmClasses.ToArray(); 45 42 } 46 43 } 47 public void UpdateAlgorithmClass(AlgorithmClass algorithmClass) { 48 using (OKBDataContext okb = new OKBDataContext()) { 49 AlgorithmClass original = okb.AlgorithmClasses.First(a => a.Id == algorithmClass.Id); 50 original.Name = algorithmClass.Name; 51 original.Description = algorithmClass.Description; 44 public void StoreAlgorithmClass(AlgorithmClass algorithmClass) { 45 using (OKBDataContext okb = new OKBDataContext()) { 46 AlgorithmClass original = okb.AlgorithmClasses.FirstOrDefault(a => a.Id == algorithmClass.Id); 47 if (original == null) { 48 okb.AlgorithmClasses.InsertOnSubmit(new AlgorithmClass() { 49 Name = algorithmClass.Name, 50 Description = algorithmClass.Description 51 }); 52 } else { 53 original.Name = algorithmClass.Name; 54 original.Description = algorithmClass.Description; 55 } 52 56 okb.SubmitChanges(); 53 57 } … … 60 64 } 61 65 62 public void AddAlgorithm(Algorithm algorithm) { 63 using (OKBDataContext okb = new OKBDataContext()) { 64 okb.Algorithms.InsertOnSubmit(new Algorithm() { 65 AlgorithmClassId = algorithm.AlgorithmClassId, 66 PlatformId = algorithm.PlatformId, 67 Name = algorithm.Name, 68 Description = algorithm.Description 69 }); 70 okb.SubmitChanges(); 71 } 72 } 73 public Algorithm[] GetAlgorithms() { 66 public Algorithm GetAlgorithm(long algorithmId) { 67 using (OKBDataContext okb = new OKBDataContext()) { 68 return okb.Algorithms.FirstOrDefault(a => a.Id == algorithmId); 69 } 70 } 71 public IEnumerable<Algorithm> GetAlgorithms() { 74 72 using (OKBDataContext okb = new OKBDataContext()) { 75 73 return okb.Algorithms.ToArray(); 76 74 } 77 75 } 78 public void UpdateAlgorithm(Algorithm algorithm) { 79 using (OKBDataContext okb = new OKBDataContext()) { 80 Algorithm original = okb.Algorithms.First(a => a.Id == algorithm.Id); 81 original.AlgorithmClassId = algorithm.AlgorithmClassId; 82 original.PlatformId = algorithm.PlatformId; 83 original.Name = algorithm.Name; 84 original.Description = algorithm.Description; 76 public void StoreAlgorithm(Algorithm algorithm) { 77 using (OKBDataContext okb = new OKBDataContext()) { 78 Algorithm original = okb.Algorithms.FirstOrDefault(a => a.Id == algorithm.Id); 79 if (original == null) { 80 okb.Algorithms.InsertOnSubmit(new Algorithm() { 81 Name = algorithm.Name, 82 Description = algorithm.Description 83 }); 84 } else { 85 original.Name = algorithm.Name; 86 original.Description = algorithm.Description; 87 } 85 88 okb.SubmitChanges(); 86 89 } -
trunk/sources/HeuristicLab.Services.OKB/3.3/Interfaces/IAdminService.cs
r4407 r4426 20 20 #endregion 21 21 22 using System.Collections.Generic; 22 23 using System.Net.Security; 23 24 using System.ServiceModel; … … 31 32 public interface IAdminService { 32 33 [OperationContract] 33 void AddAlgorithmClass(AlgorithmClass algorithmClass);34 AlgorithmClass GetAlgorithmClass(long algorithmClassId); 34 35 [OperationContract] 35 AlgorithmClass[]GetAlgorithmClasses();36 IEnumerable<AlgorithmClass> GetAlgorithmClasses(); 36 37 [OperationContract] 37 void UpdateAlgorithmClass(AlgorithmClass algorithmClass);38 void StoreAlgorithmClass(AlgorithmClass algorithmClass); 38 39 [OperationContract] 39 40 void DeleteAlgorithmClass(long algorithmClassId); 40 41 41 42 [OperationContract] 42 void AddAlgorithm(Algorithm algorithm);43 Algorithm GetAlgorithm(long algorithmId); 43 44 [OperationContract] 44 Algorithm[]GetAlgorithms();45 IEnumerable<Algorithm> GetAlgorithms(); 45 46 [OperationContract] 46 void UpdateAlgorithm(Algorithm algorithm);47 void StoreAlgorithm(Algorithm algorithm); 47 48 [OperationContract] 48 49 void DeleteAlgorithm(long algorithmId);
Note: See TracChangeset
for help on using the changeset viewer.