public void AssignFromEntry(SecurityEntry entry)
        {
            this.ID = entry.ID;
            this.CompanyID  = entry.CompanyID ;
            this.UserID = entry.UserID ;
            this.Active = entry.Active;
            this.Deleted = entry.Deleted;
            this.DateModified = entry.DateModified ;

            this.SecurityObjectID = entry.SecurityObjectID;
            this.PermissionGranted = entry.PermissionsGranted;
            this.PermissionDenied = entry.PermissionsDenied;
            this.ApplicationID = entry.ApplicationID;
            this.EntryType = entry.EntryType;
        }
        public SecurityEntry AssignToEntry()
        {
            SecurityEntry entry = new SecurityEntry();

            entry.ID = this.ID;
            entry.CompanyID = this.CompanyID ;
            entry.UserID = this.UserID ;
            entry.Active = this.Active;
            entry.Deleted = this.Deleted;
            entry.DateModified  = this.DateModified ;

            entry.SecurityObjectID = this.SecurityObjectID;
            entry.PermissionsGranted = this.PermissionGranted;
            entry.PermissionsDenied = this.PermissionDenied;
            entry.ApplicationID = this.ApplicationID;
            entry.EntryType = this.EntryType;

            return entry;
        }
        private SolutionMessageResponse AssignSecurityObjectsToEntityGeneric(SaveListRequest<SecurityObject> securityObjects, bool assignI360 = true)
        {
            /*							permissions
             * target user has		  : A B C		list1
             * editing user has		 :   B C D E	list2
             * param 'securityObjects'  :	 C D	  list3 (must be subset of list2)
             * ------------------------------------
             * to be deleted			:   B		  list4
             * to be added			  :	   D	  list5
             * target user has now	  : A   C D
             *
             * Algorithm:
             * foreach p in list2
             *   if p in list1 and p not in list3 then add to list4
             *   else if p not in list1 and p in list3 then add to list5
             */

            Guid targetID = securityObjects.Get("TargetID", Guid.Empty);
            Guid editorID = securityObjects.Get("EditorID", Guid.Empty);
            Guid appID = new Guid("B9E34B8D-F105-4E21-AFED-60F8500B9EDB");

            if (targetID == Guid.Empty || editorID == Guid.Empty)
            {
                throw new ArgumentException("Required params TargetID and EditorID");
            }

            //add back APIAccessPermission for Imarda user in case it was removed for display
            if (targetID == ImardaCompany && securityObjects.List.Find(so => so.ID == APIAccessPermission) == null)
                securityObjects.List.Add(new SecurityObject() {ID = APIAccessPermission});

            ImardaSecurityBusiness.IImardaSecurity service = ImardaProxyManager.Instance.IImardaSecurityProxy;
            ChannelInvoker.Invoke(delegate(out IClientChannel channel)
            {
                channel = service as IClientChannel;

                //retrieve existing target user list:
                var req1 = new IDRequest(targetID, "appid", appID);

                //PG20140205 - Original code was retrieving all entities I360 + IAC
                //var resp1 = service.GetEntitySecurityEntryList(req1);
                //PG20140205 - New code retrieves I360 OR IAC
                var resp1 = assignI360 ? service.GetEntitySecurityEntryListForI360(req1) : service.GetEntitySecurityEntryListForIac(req1);

                ErrorHandler.Check(resp1);
                Guid[] list1 = resp1.List.Select(se => se.SecurityObjectID).ToArray();

                //retrieve list of editing user:
                var req2 = new IDRequest(editorID, "appid", appID);

                //PG20140205 - Original code was retrieving all entities I360 + IAC
                //var resp2 = service.GetEntitySecurityEntryList(req2);
                //PG20140205 - New code retrieves I360 OR IAC
                var resp2 = assignI360 ? service.GetEntitySecurityEntryListForI360(req2) : service.GetEntitySecurityEntryListForIac(req2);

                ErrorHandler.Check(resp2);
                Guid[] list2 = resp2.List.Select(se => se.SecurityObjectID).ToArray();

                //input parameter contains assigned permissions
                Guid[] list3 = securityObjects.List.Select(so => so.ID).ToArray();

                var list4 = new List<SecurityEntryKey>(); // delete
                var list5 = new List<SecurityEntry>(); // create

                foreach (Guid id in list2)
                {
                    if (list1.Contains(id) && !list3.Contains(id))
                    {
                        // delete
                        var se = new SecurityEntryKey { EntityID = targetID, SecurityObjectID = id };
                        list4.Add(se);
                    }
                    else if (!list1.Contains(id) && list3.Contains(id))
                    {
                        // create
                        var se = new SecurityEntry();
                        se.ID = SequentialGuid.NewDbGuid();
                        se.EntityID = targetID;
                        se.SecurityObjectID = id;
                        se.EntryType = 0;
                        se.UserID = editorID;
                        se.ApplicationID = appID;
                        list5.Add(se);
                    }
                }
                var delReq = new SaveListRequest<SecurityEntryKey>(list4);
                delReq.Put("UserID", editorID);
                var resp4 = service.DeleteSecurityEntryList(delReq);
                ErrorHandler.Check(resp4);

                var createReq = new SaveListRequest<SecurityEntry>(list5);
                //editorID included in each SecurityEntry
                var resp5 = service.SaveSecurityEntryList(createReq);
                ErrorHandler.Check(resp5);
            });
            return new SolutionMessageResponse();
        }