Ejemplo n.º 1
0
 public static DevicePingDomain ToDomainModel(this EF.DevicePing obj)
 {
     return(obj == null ? null : new DevicePingDomain()
     {
         Id = obj.DevicePingId,
         TenantId = obj.TenantId,
         RuleId = obj.RuleId,
         DateCreated = obj.DateCreated,
         ActionId = obj.ActionId,
         Action = obj.Action.ToDomainModel(),
         DeviceId = obj.DeviceId,
         Device = obj.Device.ToDomainModel(),
         DevicePropertyValues = obj.DevicePropertyValue.ToDomainModelCollection()
     });
 }
Ejemplo n.º 2
0
        public bool DeleteDevicePingById(int tenantId, int id)
        {
            if (tenantId <= 0)
            {
                throw new NsiArgumentException("Invalid tenant ID");
            }

            try
            {
                EF.DevicePing devicePing = _context.DevicePing.FirstOrDefault(x => x.DevicePingId == id && x.TenantId == tenantId);

                if (devicePing != null)
                {
                    _context.DevicePing.Remove(devicePing);
                }

                _context.SaveChanges();
                return(true);
            }
            catch
            {
                return(false);
            }
        }