Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/08/11 12:39:33 (12 years ago)
Author:
ascheibe
Message:

#1233 added Appointment/Schedule ws and dao methods

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.4/HiveDao.cs

    r5593 r5633  
    9494                    where resourceIds.Contains(ar.ResourceId)
    9595                       && ar.Job.State == JobState.Waiting
    96                        && ar.Job.IsParentJob 
     96                       && ar.Job.IsParentJob
    9797                       && (finished ? ar.Job.FinishWhenChildJobsFinished : !ar.Job.FinishWhenChildJobsFinished)
    9898                       && (from child in db.Jobs
     
    581581    }
    582582    #endregion
     583
     584    #region AppointmentMethods
     585    public Appointment GetAppointment(Guid id) {
     586      using (var db = CreateContext()) {
     587        return Convert.ToDto(db.UptimeCalendars.SingleOrDefault(x => x.UptimeCalendarId == id));
     588      }
     589    }
     590
     591    public IEnumerable<Appointment> GetAppointments(Expression<Func<UptimeCalendar, bool>> predicate) {
     592      using (var db = CreateContext()) {
     593        return db.UptimeCalendars.Where(predicate).Select(x => Convert.ToDto(x)).ToArray();
     594      }
     595    }
     596
     597    public Guid AddAppointment(Appointment dto) {
     598      using (var db = CreateContext()) {
     599        var entity = Convert.ToEntity(dto);
     600        db.UptimeCalendars.InsertOnSubmit(entity);
     601        db.SubmitChanges();
     602        return entity.UptimeCalendarId;
     603      }
     604    }
     605
     606    public void UpdateAppointment(Appointment dto) {
     607      using (var db = CreateContext()) {
     608        var entity = db.UptimeCalendars.FirstOrDefault(x => x.UptimeCalendarId == dto.Id);
     609        if (entity == null) db.UptimeCalendars.InsertOnSubmit(Convert.ToEntity(dto));
     610        else Convert.ToEntity(dto, entity);
     611        db.SubmitChanges();
     612      }
     613    }
     614
     615    public void DeleteAppointment(Guid id) {
     616      using (var db = CreateContext()) {
     617        var entity = db.UptimeCalendars.FirstOrDefault(x => x.UptimeCalendarId == id);
     618        if (entity != null) db.UptimeCalendars.DeleteOnSubmit(entity);
     619        db.SubmitChanges();
     620      }
     621    }
     622    #endregion
    583623  }
    584624}
Note: See TracChangeset for help on using the changeset viewer.