public Guid AddDowntime(DT.Downtime downtimeDto) { RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client); AuthorizationManager.AuthorizeForResourceAdministration(downtimeDto.ResourceId); var pm = PersistenceManager; using (new PerformanceLogger("AddDowntime")) { var downtimeDao = pm.DowntimeDao; return(pm.UseTransaction(() => { var downtime = downtimeDao.Save(downtimeDto.ToEntity()); pm.SubmitChanges(); return downtime.ResourceId; })); } }
public void UpdateDowntime(DT.Downtime downtimeDto) { RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client); AuthorizationManager.AuthorizeForResourceAdministration(downtimeDto.ResourceId); var pm = PersistenceManager; using (new PerformanceLogger("UpdateDowntime")) { var downtimeDao = pm.DowntimeDao; pm.UseTransaction(() => { var downtime = downtimeDao.GetById(downtimeDto.Id); if (downtime != null) { downtimeDto.CopyToEntity(downtime); } else { downtimeDao.Save(downtimeDto.ToEntity()); } pm.SubmitChanges(); }); } }