public async Task <IHttpActionResult> ChangeAddress(ChangeBusinessAddressRequest changeBusinessAddressRequest) { // if the user is null or the user is not authenticated if (!IsUserAuthenticated) { return(Content(HttpStatusCode.Unauthorized, "User must be logged to get businesses.")); } var ownerId = UserId; var myBusinesses = db.BusinessUsers.Where( businessUser => businessUser.UserId == ownerId && businessUser.BusinessId == changeBusinessAddressRequest.BusinessId) .Include(businessUser => businessUser.Business).FirstOrDefault(); var newBusiness = myBusinesses.Business; newBusiness.Address = changeBusinessAddressRequest.GetAddressString(); newBusiness.Postcode = changeBusinessAddressRequest.Postcode; newBusiness.Location = PostcodesService.Lookup(changeBusinessAddressRequest.Postcode); await db.SaveChangesAsync(); return(Ok()); }
private static void ChangeAddressAction(Guid id) { Console.WriteLine("Change Address"); ChangeBusinessAddressRequest request = new ChangeBusinessAddressRequest(); FillBusinessAddress(request); request.BusinessId = id; try { bookingBlockClient.BusinessesChangeAddress(request); } catch (Exception exception) { Console.WriteLine("ERROR: " + exception.Message); } }
public void BusinessesChangeAddress(ChangeBusinessAddressRequest request) { var q = httpClient.PostAsJsonAsync(AddApiKey("api/businesses/change-address"), request).Result; q.EnsureSuccessStatusCode(); }