public ResponseAccount GetAccountByPhoneNumber(PhoneNumberRequest req) { ResponseAccount retVal = new ResponseAccount(); retVal.Account = SQLGetAccount(config.getAccountByPhoneNumber.Replace("%1", req.PhoneNumber)); return retVal; }
public ResponseAccount GetAccountByPhoneNumber(PhoneNumberRequest req) { ResponseAccount retVal = new ResponseAccount(); String phoneNumber = req.PhoneNumber; var acc = from account in accounts where HasPhoneNumber(account.PhoneNumbers.PhoneNumber,phoneNumber) select account; if (acc.Count() < 1) { throw new WebFaultException(HttpStatusCode.NoContent); } else if (acc.Count() > 1) { throw new WebFaultException(HttpStatusCode.Conflict); } Account retAccount = new Account(acc.FirstOrDefault()); if (retAccount != null && req.CustomAttribute != null && req.CustomAttribute.Equals("overwrite")) { retAccount.CustomAttribute = "overwritten custom attribute"; } retVal.Account = retAccount; return retVal; }
public ResponseContact GetContactByPhoneNumber(PhoneNumberRequest req) { ResponseContact rc = new ResponseContact(); rc.Contact = SQLGetContact(config.getContactByPhoneNumber.Replace("%1", req.PhoneNumber)); return rc; }
public ResponseContact GetContactByPhoneNumber(PhoneNumberRequest req) { string phoneNumber = req.PhoneNumber; ResponseContact rc = new ResponseContact(); var ct = from contact in contacts where HasPhoneNumber(contact.PhoneNumbers.PhoneNumber, phoneNumber) select contact; if (ct.Count() < 1) { throw new WebFaultException(HttpStatusCode.NoContent); } else if (ct.Count() > 1) { throw new WebFaultException(HttpStatusCode.Conflict); } Contact retContact = new Contact(ct.FirstOrDefault()); if ((retContact != null) && (req.CustomAttribute != null)) { if (req.CustomAttribute.Equals("overwrite")) { retContact.CustomAttribute = "overwritten custom attribute"; } else if (req.CustomAttribute.Equals("error_never_return")) { Thread.Sleep(System.Threading.Timeout.Infinite); } else if (req.CustomAttribute.Equals("error_internal_server")) { throw new WebFaultException<string>("Thrown because error_internal_server was the custom attribute", HttpStatusCode.InternalServerError); } } rc.Contact = retContact; return rc; }