Beispiel #1
0
 public static void ToEntity(DT.Downtime source, DB.Downtime target)
 {
     if ((source != null) && (target != null))
     {
         target.DowntimeId = source.Id; target.AllDayEvent = source.AllDayEvent; target.EndDate = source.EndDate; target.Recurring = source.Recurring; target.RecurringId = source.RecurringId; target.ResourceId = source.ResourceId; target.StartDate = source.StartDate; target.DowntimeType = source.DowntimeType;
     }
 }
Beispiel #2
0
        public static DB.Downtime ToEntity(DT.Downtime source)
        {
            if (source == null)
            {
                return(null);
            }
            var entity = new DB.Downtime(); ToEntity(source, entity);

            return(entity);
        }
Beispiel #3
0
        public static DA.Downtime ToEntity(this DT.Downtime source)
        {
            if (source == null)
            {
                return(null);
            }
            var result = new DA.Downtime();

            source.CopyToEntity(result);
            return(result);
        }
Beispiel #4
0
 public static void CopyToEntity(this DT.Downtime source, DA.Downtime target)
 {
     if ((source == null) || (target == null))
     {
         return;
     }
     target.DowntimeId   = source.Id;
     target.AllDayEvent  = source.AllDayEvent;
     target.EndDate      = source.EndDate;
     target.Recurring    = source.Recurring;
     target.RecurringId  = source.RecurringId;
     target.ResourceId   = source.ResourceId;
     target.StartDate    = source.StartDate;
     target.DowntimeType = source.DowntimeType;
 }
        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();
                });
            }
        }