Browse Source

Changes un Basket logic to adapt to websites logic

pull/49/merge
Javier Suárez Ruiz 8 years ago
parent
commit
5f32ca1947
5 changed files with 18 additions and 85 deletions
  1. +9
    -23
      src/Mobile/eShopOnContainers/eShopOnContainers.Core/ViewModels/BasketViewModel.cs
  2. +5
    -19
      src/Mobile/eShopOnContainers/eShopOnContainers.Core/Views/ProfileView.xaml
  3. +2
    -20
      src/Mobile/eShopOnContainers/eShopOnContainers.Core/Views/Templates/BasketItemTemplate.xaml
  4. +2
    -20
      src/Mobile/eShopOnContainers/eShopOnContainers.Core/Views/Templates/OrderItemTemplate.xaml
  5. +0
    -3
      src/Mobile/eShopOnContainers/eShopOnContainers.Core/Views/Templates/ProductTemplate.xaml

+ 9
- 23
src/Mobile/eShopOnContainers/eShopOnContainers.Core/ViewModels/BasketViewModel.cs View File

@ -99,39 +99,25 @@ namespace eShopOnContainers.Core.ViewModels
private void AddCatalogItem(CatalogItem item)
{
if (BasketItems.Any(o => o.ProductId.Equals(item.Id, StringComparison.CurrentCultureIgnoreCase)))
BasketItems.Add(new BasketItem
{
var orderItem = BasketItems.First(o => o.ProductId.Equals(item.Id, StringComparison.CurrentCultureIgnoreCase));
orderItem.Quantity++;
}
else
{
BasketItems.Add(new BasketItem
{
ProductId = item.Id,
ProductName = item.Name,
PictureUrl = item.PictureUri,
UnitPrice = item.Price,
Quantity = 1
});
}
ProductId = item.Id,
ProductName = item.Name,
PictureUrl = item.PictureUri,
UnitPrice = item.Price,
Quantity = 1
});
ReCalculateTotal();
}
private void AddItem(BasketItem parameter)
private void AddItem(BasketItem item)
{
BadgeCount++;
var basketItem = BasketItems
.FirstOrDefault(bi => bi.ProductId.Equals(parameter.ProductId,
StringComparison.CurrentCultureIgnoreCase));
basketItem.Quantity++;
AddBasketItem(item);
RaisePropertyChanged(() => BasketItems);
ReCalculateTotal();
}
private void AddBasketItem(BasketItem item)


+ 5
- 19
src/Mobile/eShopOnContainers/eShopOnContainers.Core/Views/ProfileView.xaml View File

@ -9,14 +9,6 @@
<ContentPage.Resources>
<ResourceDictionary>
<Style x:Key="LogoutLabelStyle"
TargetType="{x:Type Label}">
<Setter Property="HorizontalOptions"
Value="Center" />
<Setter Property="VerticalOptions"
Value="Center" />
</Style>
<Style x:Key="LoginButtonStyle"
TargetType="{x:Type Label}">
<Setter Property="FontFamily"
@ -55,18 +47,12 @@
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<!-- LOG OUT BUTTON -->
<Grid
<Button
Grid.Row="0"
BackgroundColor="{StaticResource GrayColor}">
<Label
Text="LOG OUT"
Style="{StaticResource LogoutLabelStyle}"/>
<Grid.GestureRecognizers>
<TapGestureRecognizer
Command="{Binding LogoutCommand}"
NumberOfTapsRequired="1" />
</Grid.GestureRecognizers>
</Grid>
Text="LOG OUT"
TextColor="{StaticResource BlackColor}"
BackgroundColor="{StaticResource GrayColor}"
Command="{Binding LogoutCommand}" />
<!-- ORDERS -->
<Grid
Grid.Row="1">


+ 2
- 20
src/Mobile/eShopOnContainers/eShopOnContainers.Core/Views/Templates/BasketItemTemplate.xaml View File

@ -86,33 +86,15 @@
<RowDefinition Height="1" />
</Grid.RowDefinitions>
<!-- IMAGE -->
<ffimageloading:CachedImage
<Image
Grid.Column="0"
Grid.Row="0"
Source="{Binding PictureUrl, Converter={StaticResource ImageConverter}}"
CacheDuration="30"
CacheType="Disk"
DownsampleToViewSize="True"
HeightRequest="108"
WidthRequest="108"
Aspect="AspectFit"
VerticalOptions="Start"
Margin="12,0,0,0">
<ffimageloading:CachedImage.LoadingPlaceholder>
<OnPlatform
x:TypeArguments="ImageSource"
iOS="default_product"
Android="default_product"
WinPhone="Assets/default_product.png"/>
</ffimageloading:CachedImage.LoadingPlaceholder>
<ffimageloading:CachedImage.ErrorPlaceholder>
<OnPlatform
x:TypeArguments="ImageSource"
iOS="noimage"
Android="noimage"
WinPhone="Assets/noimage.png"/>
</ffimageloading:CachedImage.ErrorPlaceholder>
</ffimageloading:CachedImage>
Margin="12,0,0,0" />
<Grid
Grid.Column="1"
Grid.Row="0"


+ 2
- 20
src/Mobile/eShopOnContainers/eShopOnContainers.Core/Views/Templates/OrderItemTemplate.xaml View File

@ -70,33 +70,15 @@
<RowDefinition Height="1" />
</Grid.RowDefinitions>
<!-- IMAGE -->
<ffimageloading:CachedImage
<Image
Grid.Column="0"
Grid.Row="0"
Source="{Binding PictureUrl, Converter={StaticResource ImageConverter}}"
CacheDuration="30"
CacheType="Disk"
DownsampleToViewSize="True"
HeightRequest="108"
WidthRequest="108"
Aspect="AspectFit"
VerticalOptions="Start"
Margin="12,0,0,0">
<ffimageloading:CachedImage.LoadingPlaceholder>
<OnPlatform
x:TypeArguments="ImageSource"
iOS="default_product"
Android="default_product"
WinPhone="Assets/default_product.png"/>
</ffimageloading:CachedImage.LoadingPlaceholder>
<ffimageloading:CachedImage.ErrorPlaceholder>
<OnPlatform
x:TypeArguments="ImageSource"
iOS="noimage"
Android="noimage"
WinPhone="Assets/noimage.png"/>
</ffimageloading:CachedImage.ErrorPlaceholder>
</ffimageloading:CachedImage>
Margin="12,0,0,0" />
<Grid
Grid.Column="1"
Grid.Row="0"


+ 0
- 3
src/Mobile/eShopOnContainers/eShopOnContainers.Core/Views/Templates/ProductTemplate.xaml View File

@ -74,9 +74,6 @@
<ffimageloading:CachedImage
Grid.Row="0"
Source="{Binding PictureUri}"
CacheDuration="30"
CacheType="Disk"
DownsampleToViewSize="True"
Aspect="AspectFill">
<ffimageloading:CachedImage.LoadingPlaceholder>
<OnPlatform


Loading…
Cancel
Save