- Timestamp:
- 09/20/10 05:16:33 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Services.OKB/3.3/AdminService.cs
r4434 r4442 32 32 [ServiceBehavior(IncludeExceptionDetailInFaults = true)] 33 33 public class AdminService : IAdminService { 34 #region Platform Methods 35 public Platform GetPlatform(long platformId) { 36 using (OKBDataContext okb = new OKBDataContext()) { 37 return okb.Platforms.FirstOrDefault(p => p.Id == platformId); 38 } 39 } 40 public IEnumerable<Platform> GetPlatforms() { 41 using (OKBDataContext okb = new OKBDataContext()) { 42 return okb.Platforms.ToArray(); 43 } 44 } 45 public void StorePlatform(Platform platform) { 46 using (OKBDataContext okb = new OKBDataContext()) { 47 Platform original = okb.Platforms.FirstOrDefault(p => p.Id == platform.Id); 48 if (original == null) { 49 okb.Platforms.InsertOnSubmit(new Platform() { 50 Name = platform.Name, 51 Description = platform.Description 52 }); 53 } else { 54 original.Name = platform.Name; 55 original.Description = platform.Description; 56 } 57 okb.SubmitChanges(); 58 } 59 } 60 public void DeletePlatform(long platformId) { 61 using (OKBDataContext okb = new OKBDataContext()) { 62 Platform platform = okb.Platforms.FirstOrDefault(p => p.Id == platformId); 63 if (platform != null) { 64 okb.Platforms.DeleteOnSubmit(platform); 65 okb.SubmitChanges(); 66 } 67 } 68 } 69 #endregion 70 71 #region AlgorithmClass Methods 34 72 public AlgorithmClass GetAlgorithmClass(long algorithmClassId) { 35 73 using (OKBDataContext okb = new OKBDataContext()) { … … 66 104 } 67 105 } 68 106 #endregion 107 108 #region Algorithm Methods 69 109 public Algorithm GetAlgorithm(long algorithmId) { 70 110 using (OKBDataContext okb = new OKBDataContext()) { … … 83 123 okb.Algorithms.InsertOnSubmit(new Algorithm() { 84 124 Name = algorithm.Name, 85 Description = algorithm.Description 125 Description = algorithm.Description, 126 PlatformId = algorithm.PlatformId, 127 AlgorithmClassId = algorithm.AlgorithmClassId 86 128 }); 87 129 } else { 88 130 original.Name = algorithm.Name; 89 131 original.Description = algorithm.Description; 132 original.PlatformId = algorithm.PlatformId; 133 original.AlgorithmClassId = algorithm.AlgorithmClassId; 90 134 } 91 135 okb.SubmitChanges(); … … 101 145 } 102 146 } 103 104 /// <summary> 105 /// Gets all available platforms. 106 /// </summary> 107 /// <returns>A list of <see cref="Platform"/>s.</returns> 108 public Platform[] GetPlatforms() { 109 using (OKBDataContext okb = new OKBDataContext()) { 110 return okb.Platforms.ToArray(); 111 } 112 } 147 #endregion 113 148 114 149 /// <summary>
Note: See TracChangeset
for help on using the changeset viewer.