/// <summary>
        /// Remove selected device template
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public GXDeviceProfilesDeleteResponse Post(GXDeviceProfilesDeleteRequest request)
        {
            List <GXEventsItem> events = new List <GXEventsItem>();
            IAuthSession        s      = this.GetSession(false);
            int id = Convert.ToInt32(s.Id);

            if (id == 0)
            {
                throw new ArgumentException("Remove failed. Invalid session ID.");
            }
            bool superAdmin = GuruxAMI.Server.GXBasicAuthProvider.IsSuperAdmin(s);

            lock (Db)
            {
                foreach (ulong it in request.DeviceProfileIDs)
                {
                    if (it == 0)
                    {
                        throw new ArgumentException("ID is required");
                    }
                    if (!superAdmin && GetDeviceProfiles(s, Db, id, 0, false, null, false).Count == 0)
                    {
                        throw new ArgumentException("Access denied.");
                    }
#if !SS4
                    GXAmiDeviceProfile dt = Db.GetById <GXAmiDeviceProfile>(it);
#else
                    GXAmiDeviceProfiles dt = Db.SingleById <GXAmiDeviceProfiles>(it);
#endif
                    if (request.Permanently)
                    {
                        Db.DeleteById <GXAmiDeviceProfile>(it);
                    }
                    else
                    {
                        Db.UpdateOnly(new GXAmiDeviceProfile {
                            Removed = DateTime.Now
                        }, p => p.Removed, p => p.Id == it);
                    }
                    events.Add(new GXEventsItem(ActionTargets.DeviceProfile, Actions.Remove, dt));
                }
            }
            AppHost host = this.ResolveService <AppHost>();
            host.SetEvents(Db, this.Request, 0, events);
            return(new GXDeviceProfilesDeleteResponse());
        }
        /// <summary>
        /// Remove selected device template
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
		public GXDeviceProfilesDeleteResponse Post(GXDeviceProfilesDeleteRequest request)
		{
            List<GXEventsItem> events = new List<GXEventsItem>();
            IAuthSession s = this.GetSession(false);
            int id = Convert.ToInt32(s.Id);
            if (id == 0)
            {
                throw new ArgumentException("Remove failed. Invalid session ID.");
            }
            bool superAdmin = GuruxAMI.Server.GXBasicAuthProvider.IsSuperAdmin(s);
            lock (Db)
            {
                foreach (ulong it in request.DeviceProfileIDs)
                {
                    if (it == 0)
                    {
                        throw new ArgumentException("ID is required");
                    }
                    if (!superAdmin && GetDeviceProfiles(s, Db, id, 0, false, null, false).Count == 0)
                    {
                        throw new ArgumentException("Access denied.");
                    }
#if !SS4
                    GXAmiDeviceProfile dt = Db.GetById<GXAmiDeviceProfile>(it);
#else
                    GXAmiDeviceProfiles dt = Db.SingleById<GXAmiDeviceProfiles>(it);                    
#endif                                                
                    if (request.Permanently)
                    {
                        Db.DeleteById<GXAmiDeviceProfile>(it);
                    }
                    else
                    {
                        Db.UpdateOnly(new GXAmiDeviceProfile { Removed = DateTime.Now }, p => p.Removed, p => p.Id == it);
                    }
                    events.Add(new GXEventsItem(ActionTargets.DeviceProfile, Actions.Remove, dt));
                }
            }
            AppHost host = this.ResolveService<AppHost>();
            host.SetEvents(Db, this.Request, 0, events);
            return new GXDeviceProfilesDeleteResponse();
        }