Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/19/10 05:25:41 (14 years ago)
Author:
swagner
Message:

Worked on OKB data model and services (#1174)

File:
1 edited

Legend:

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

    r4426 r4434  
    5959    public void DeleteAlgorithmClass(long algorithmClassId) {
    6060      using (OKBDataContext okb = new OKBDataContext()) {
    61         okb.AlgorithmClasses.DeleteOnSubmit(okb.AlgorithmClasses.First(a => a.Id == algorithmClassId));
    62         okb.SubmitChanges();
     61        AlgorithmClass algorithmClass = okb.AlgorithmClasses.FirstOrDefault(a => a.Id == algorithmClassId);
     62        if (algorithmClass != null) {
     63          okb.AlgorithmClasses.DeleteOnSubmit(algorithmClass);
     64          okb.SubmitChanges();
     65        }
    6366      }
    6467    }
     
    9194    public void DeleteAlgorithm(long algorithmId) {
    9295      using (OKBDataContext okb = new OKBDataContext()) {
    93         okb.Algorithms.DeleteOnSubmit(okb.Algorithms.First(a => a.Id == algorithmId));
    94         okb.SubmitChanges();
     96        Algorithm algorithm = okb.Algorithms.FirstOrDefault(a => a.Id == algorithmId);
     97        if (algorithm != null) {
     98          okb.Algorithms.DeleteOnSubmit(algorithm);
     99          okb.SubmitChanges();
     100        }
    95101      }
    96102    }
Note: See TracChangeset for help on using the changeset viewer.