public async Task CreateOrder(CreateOrderFormModel formModel) { var request = new CreateOrderRequest { FirstName = formModel.FirstName, LastName = formModel.LastName, Email = formModel.Email, City = formModel.City, Comment = string.Empty, CountryId = formModel.CountryId, Region = formModel.Region, SaveShippingInfo = false, StreetAddress = formModel.StreetAddress, StreetAddressSecondLine = formModel.StreetAddressSecondLine ?? string.Empty, ZipCode = formModel.ZipCode }; var orderItems = cartService.GetAutoParts() .Select(cartItem => new OrderItem { AutoPartId = cartItem.AutoPart.Id, Quantity = cartItem.Quantity }) .ToArray(); request.OrderItems.AddRange(orderItems); var headers = RequestHeadersUtility.GetRequestHeaders(localStorage); await orderServiceClient.CreateOrderAsync(request, headers); }
public async Task <SupplierPrivateProfile> GetSupplierProfile() { var request = new GetCurrentUserSupplierPrivateProfileRequest(); var headers = RequestHeadersUtility.GetRequestHeaders(localStorage); var response = await supplierServiceClient.GetCurrentUserSupplierPrivateProfileAsync(request, headers); return(response.Model); }
public async Task <GetOrderResponse> GetOrder(long orderId) { var request = new GetOrderRequest { OrderId = orderId }; var headers = RequestHeadersUtility.GetRequestHeaders(localStorage); return(await orderServiceClient.GetOrderAsync(request, headers)); }
public async Task <ServiceResponse> DeleteCarBrand(long carBrandId) { var request = new DeleteCarBrandRequest { Id = carBrandId }; var headers = RequestHeadersUtility.GetRequestHeaders(localStorage); return(await carBrandServiceClient.DeleteCarBrandAsync(request, headers)); }
public async Task <ServiceResponse> DeleteManufacturer(long manufacturerId) { var request = new DeleteManufacturerRequest { Id = manufacturerId }; var headers = RequestHeadersUtility.GetRequestHeaders(localStorage); return(await manufacturerServiceClient.DeleteManufacturerAsync(request, headers)); }
public async Task <OrderAutoPart[]> GetOrderItems(long orderId) { var request = new GetOrderItemsRequest { OrderId = orderId }; var headers = RequestHeadersUtility.GetRequestHeaders(localStorage); var response = await orderServiceClient.GetOrderItemsAsync(request, headers); return(response.Items.ToArray()); }
public async Task <GetSupplierOrdersResponse> GetSupplierOrders(int pageNumber, int pageSize) { var filter = new PaginationFilter { PageNumber = pageNumber, PageSize = pageSize }; var headers = RequestHeadersUtility.GetRequestHeaders(localStorage); return(await orderServiceClient.GetSupplierOrdersAsync(filter, headers)); }
private async Task <GetCurrentUserInfoResponse> GetCurrentUserInfo() { try { var requestHeaders = RequestHeadersUtility.GetRequestHeaders(localStorage); return(await userServiceClient.GetCurrentUserInfoAsync(new GetCurrentUserInfoRequest(), requestHeaders)); } catch { return(null); } }
public async Task <ServiceResponse> CreateAutoPart(AutoPartFormModel formModel) { var request = CreateGetAutoPartRequestFromFormModel(formModel); if (formModel.ImageFileInfo != null && formModel.ImageFileBuffer != null) { request.ImageFileName = formModel.ImageFileInfo.Name; request.ImageFileBuffer = ByteString.CopyFrom(formModel.ImageFileBuffer); } var headers = RequestHeadersUtility.GetRequestHeaders(localStorage); return(await autoPartServiceClient.CreateAutoPartAsync(request, headers)); }
public async Task <ServiceResponse> UpdateCarModification(long carModificationId, CarModificationFormModel formModel) { var request = new UpdateCarModificationRequest { Id = carModificationId, Name = formModel.Name, Description = formModel.Description, Year = int.Parse(formModel.Year) }; var headers = RequestHeadersUtility.GetRequestHeaders(localStorage); return(await carModificationServiceClient.UpdateCarModificationAsync(request, headers)); }
public async Task <ServiceResponse> CreateCarBrand(CarBrandFormModel formModel) { var request = new CreateCarBrandRequest { Name = formModel.Name, ImageName = string.Empty, Image = ByteString.Empty }; if (formModel.ImageFileInfo != null && formModel.ImageBuffer != null) { request.ImageName = formModel.ImageFileInfo.Name; request.Image = ByteString.CopyFrom(formModel.ImageBuffer); } var headers = RequestHeadersUtility.GetRequestHeaders(localStorage); return(await carBrandServiceClient.CreateCarBrandAsync(request, headers)); }
public async Task <ServiceResponse> CreateManufacturer(ManufacturerFormModel formModel) { var request = new CreateManufacturerRequest { CountryId = formModel.CountryId, Name = formModel.Name, Description = formModel.Description, ImageFileName = string.Empty, ImageFileBuffer = ByteString.Empty }; if (formModel.ImageFileInfo != null && formModel.ImageBuffer != null) { request.ImageFileName = formModel.ImageFileInfo.Name; request.ImageFileBuffer = ByteString.CopyFrom(formModel.ImageBuffer); } var headers = RequestHeadersUtility.GetRequestHeaders(localStorage); return(await manufacturerServiceClient.CreateManufacturerAsync(request, headers)); }
public async Task SignOut() { currentUserProvider.SetUserInfoLoading(true); try { if (localStorage.HasRefreshToken()) { var refreshToken = localStorage.GetRefreshToken(); var requestHeaders = RequestHeadersUtility.GetRequestHeaders(localStorage); await userServiceClient.SignOutAsync(new SignOutRequest { RefreshToken = refreshToken }, requestHeaders); } } finally { localStorage.RemoveAuthorizationTokens(); currentUserProvider.SetCurrentUserInfo(null); } }
public async Task <ServiceResponse> UpdateSupplierProfile(SupplierProfileFormModel formModel) { var request = new UpdateSupplierProfileRequest { Name = formModel.OrganizationName, OrganizationAddress = formModel.OrganizationAddress, OrganizationDescription = formModel.OrganizationDescription, Website = formModel.Website, SalesEmail = formModel.SalesEmail, SalesPhoneNumber = formModel.SalesPhoneNumber, LogoFileName = string.Empty, LogoFileBuffer = ByteString.Empty }; if (formModel.LogoFileInfo != null && formModel.LogoBuffer != null) { request.LogoFileName = formModel.LogoFileInfo.Name; request.LogoFileBuffer = ByteString.CopyFrom(formModel.LogoBuffer); } var headers = RequestHeadersUtility.GetRequestHeaders(localStorage); return(await supplierServiceClient.UpdateSupplierProfileAsync(request, headers)); }
public async Task <bool> GetRefreshedToken() { if (localStorage.HasRefreshToken()) { var refreshToken = localStorage.GetRefreshToken(); var requestHeaders = RequestHeadersUtility.GetRequestHeaders(localStorage); var response = await userServiceClient.GetRefreshedTokenAsync(new GetRefreshedTokenRequest { RefreshToken = refreshToken }, requestHeaders); if (!response.IsError) { localStorage.SetAuthorizationTokens(response.TokenType, response.AccessToken, response.RefreshToken); } else { localStorage.RemoveAuthorizationTokens(); } return(!response.IsError); } return(false); }
public async Task <ServiceResponse> InviteSupplier(InviteSupplierFormModel form) { var headers = RequestHeadersUtility.GetRequestHeaders(localStorage); return(await supplierServiceClient.InviteSupplierAsync(new InviteSupplierRequest { Email = form.Email, Name = form.Name }, headers)); }