public IHttpActionResult GetAddressWithID([FromUri] int AddressID, [FromUri] string lang = "en", [FromUri] string extra = "") { using (CSSPDBContext db = new CSSPDBContext(DatabaseType)) { AddressService addressService = new AddressService(new Query() { Language = (lang == "fr" ? LanguageEnum.fr : LanguageEnum.en) }, db, ContactID); addressService.Query = addressService.FillQuery(typeof(Address), lang, 0, 1, "", "", extra); if (addressService.Query.Extra == "A") { AddressExtraA addressExtraA = new AddressExtraA(); addressExtraA = addressService.GetAddressExtraAWithAddressID(AddressID); if (addressExtraA == null) { return(NotFound()); } return(Ok(addressExtraA)); } else if (addressService.Query.Extra == "B") { AddressExtraB addressExtraB = new AddressExtraB(); addressExtraB = addressService.GetAddressExtraBWithAddressID(AddressID); if (addressExtraB == null) { return(NotFound()); } return(Ok(addressExtraB)); } else { Address address = new Address(); address = addressService.GetAddressWithAddressID(AddressID); if (address == null) { return(NotFound()); } return(Ok(address)); } } }
public AddressTest() { address = new Address(); addressExtraA = new AddressExtraA(); addressExtraB = new AddressExtraB(); }