Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/20/10 05:16:33 (14 years ago)
Author:
swagner
Message:

Worked on OKB (#1174)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Services.OKB/3.3/AdminService.cs

    r4434 r4442  
    3232  [ServiceBehavior(IncludeExceptionDetailInFaults = true)]
    3333  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
    3472    public AlgorithmClass GetAlgorithmClass(long algorithmClassId) {
    3573      using (OKBDataContext okb = new OKBDataContext()) {
     
    66104      }
    67105    }
    68 
     106    #endregion
     107
     108    #region Algorithm Methods
    69109    public Algorithm GetAlgorithm(long algorithmId) {
    70110      using (OKBDataContext okb = new OKBDataContext()) {
     
    83123          okb.Algorithms.InsertOnSubmit(new Algorithm() {
    84124            Name = algorithm.Name,
    85             Description = algorithm.Description
     125            Description = algorithm.Description,
     126            PlatformId = algorithm.PlatformId,
     127            AlgorithmClassId = algorithm.AlgorithmClassId
    86128          });
    87129        } else {
    88130          original.Name = algorithm.Name;
    89131          original.Description = algorithm.Description;
     132          original.PlatformId = algorithm.PlatformId;
     133          original.AlgorithmClassId = algorithm.AlgorithmClassId;
    90134        }
    91135        okb.SubmitChanges();
     
    101145      }
    102146    }
    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
    113148
    114149    /// <summary>
Note: See TracChangeset for help on using the changeset viewer.