public HttpResponseMessage <Adopter> AssignLand(int transaction, string username, string name, int amount, int area, HttpRequestMessage request) { var prop = OperationContext.Current.IncomingMessageProperties[RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty; bool isAllowed = false; foreach (var ip in Constants.AllowedIps) { if (ip.Equals(prop.Address)) { isAllowed = true; } } if (!isAllowed) { return new HttpResponseMessage <Adopter>(null) { StatusCode = HttpStatusCode.Forbidden } } ; //Create and assign land var adopter = new Adopter { username = username, name = name, amount = amount, area = area, transaction_nr = transaction }; adopter = _donationRepository.AssignLand(adopter); if (adopter == null) { return new HttpResponseMessage <Adopter>(null) { StatusCode = HttpStatusCode.BadRequest } } ; //Add to database adopter = _donationRepository.AddAdopter(adopter); if (adopter == null) { return new HttpResponseMessage <Adopter>(null) { StatusCode = HttpStatusCode.BadRequest } } ; //Return Adopter with assigned land return(new HttpResponseMessage <Adopter>(adopter) { StatusCode = HttpStatusCode.OK }); } } }