public ResponseAccount GetAccountByContactId(ContactIdRequest cidr)
 {
     var contactId = cidr.ContactId;
     var car = from ca in contactAccountRelationships where ca.ContactId.Equals(contactId) select ca;
     if (car.Count() < 1)
     {
         throw new WebFaultException(HttpStatusCode.NoContent);
     }
     else if (car.Count() > 1)
     {
         throw new WebFaultException(HttpStatusCode.Conflict);
     }
     ContactAccountRelationship rel = car.FirstOrDefault();
     AccountNumberRequest anr = new AccountNumberRequest {
         AccountNumber = rel.AccountNumber,
         CustomAttribute = cidr.CustomAttribute
     };
     return GetAccountByAccountNumber(anr);
 }
        public ResponseCase GetMostRecentOpenCaseByContactId(ContactIdRequest cidr)
        {

            throw new WebFaultException(HttpStatusCode.NotImplemented);
        }
 public ResponseAccount GetAccountByContactId(ContactIdRequest cidr)
 {
     ResponseAccount retVal = new ResponseAccount();
     retVal.Account = SQLGetAccount(config.getAccountByAccountNumber.Replace("%1", cidr.ContactId)); ;
     return retVal;
 }
        public ResponseCase GetMostRecentOpenCaseByContactId(ContactIdRequest cidr)
        {
            ResponseCase rc = new ResponseCase();
            var caseList = from myCase in cases where myCase.ContactId == cidr.ContactId select myCase;
            if (caseList.Count() < 1)
            {
                throw new WebFaultException(HttpStatusCode.NoContent);
            }
            else if (caseList.Count() > 1)
            {
                throw new WebFaultException(HttpStatusCode.Conflict);
            }
            Case retCase = new Case(caseList.FirstOrDefault());
            rc.Case = retCase;
            if (retCase != null && cidr.CustomAttribute != null && cidr.CustomAttribute.Equals("overwrite"))
            {
                retCase.CustomAttribute = "overwritten custom attribute";
            }

            return rc;
        }