public Organization Execute(EditOrganizationCommandParams cmdParams)
        {
            var unitOfWork = _serviceFactory.GetService <IUnitOfWork>();

            // Retrieve the organization
            var org = unitOfWork.Organizations.Fetch().Where(x => x.Id == cmdParams.OrganizationId).SingleOrDefault();

            if (org == null)
            {
                throw new MJLEntityNotFoundException(typeof(Organization), cmdParams.OrganizationId);
            }

            // Edit the organization's details
            if (cmdParams.Name != null)
            {
                org.Name = cmdParams.Name;
            }
            if (cmdParams.IsEmailDomainRestrictedValue != null)
            {
                org.IsEmailDomainRestricted = (bool)cmdParams.IsEmailDomainRestrictedValue;
            }

            if (cmdParams.EmailDomainRestriction != null)
            {
                org.EmailDomains.Clear();
                org.EmailDomains.Add(new OrganizationEmailDomain {
                    Domain = cmdParams.EmailDomainRestriction
                });
            }

            // Save the organization
            unitOfWork.Commit();

            return(org);
        }
        public Organization Execute(EditOrganizationCommandParams cmdParams)
        {
            var unitOfWork = _serviceFactory.GetService<IUnitOfWork>();

            // Retrieve the organization
            var org = unitOfWork.Organizations.Fetch().Where(x => x.Id == cmdParams.OrganizationId).SingleOrDefault();
            if (org == null)
                throw new MJLEntityNotFoundException(typeof(Organization), cmdParams.OrganizationId);
            
            // Edit the organization's details
            if (cmdParams.Name != null) { org.Name = cmdParams.Name; }
            if (cmdParams.IsEmailDomainRestrictedValue != null) { org.IsEmailDomainRestricted = (bool)cmdParams.IsEmailDomainRestrictedValue; }

            if (cmdParams.EmailDomainRestriction != null)
            {
                org.EmailDomains.Clear();
                org.EmailDomains.Add(new OrganizationEmailDomain { Domain = cmdParams.EmailDomainRestriction });
            }

            // Save the organization
            unitOfWork.Commit();

            return org;
        }