public IHttpActionResult GetCompanyMembers(CorporateMembersSearchCriteria criteria)
        {
            if (criteria == null)
            {
                criteria = new CorporateMembersSearchCriteria();
            }

            GenericSearchResult <Member> members = _memberSearchService.SearchMembers(criteria);
            var ids = members.Results.Select(m => m.Id).ToArray();

            members.Results = _memberService.GetByIds(ids);
            return(Ok(members));
        }
        public IHttpActionResult UpdateCompany(Company company)
        {
            var searchCriteria = new CorporateMembersSearchCriteria {
                Name = company.Name, MemberType = typeof(Company).Name
            };
            var alreadyExistCompany = _memberSearchService.SearchMembers(searchCriteria);

            // Company must have uniquie name. If there is already exist company with the same name, return an error
            if (!alreadyExistCompany.Results.IsNullOrEmpty() && alreadyExistCompany.Results.First().Id != company.Id)
            {
                return(BadRequest(string.Format(B2BCustomerResources.CompanyAlreadyExist, company.Name)));
            }
            _memberService.SaveChanges(new[] { company });
            return(StatusCode(HttpStatusCode.NoContent));
        }