Changes un Basket logic to adapt to websites logic

This commit is contained in:
Javier Suárez Ruiz 2017-01-10 18:18:41 +01:00
parent 4d58ee27a9
commit 5f32ca1947
5 changed files with 18 additions and 85 deletions

View File

@ -98,13 +98,6 @@ namespace eShopOnContainers.Core.ViewModels
} }
private void AddCatalogItem(CatalogItem item) private void AddCatalogItem(CatalogItem item)
{
if (BasketItems.Any(o => o.ProductId.Equals(item.Id, StringComparison.CurrentCultureIgnoreCase)))
{
var orderItem = BasketItems.First(o => o.ProductId.Equals(item.Id, StringComparison.CurrentCultureIgnoreCase));
orderItem.Quantity++;
}
else
{ {
BasketItems.Add(new BasketItem BasketItems.Add(new BasketItem
{ {
@ -114,24 +107,17 @@ namespace eShopOnContainers.Core.ViewModels
UnitPrice = item.Price, UnitPrice = item.Price,
Quantity = 1 Quantity = 1
}); });
}
ReCalculateTotal(); ReCalculateTotal();
} }
private void AddItem(BasketItem parameter) private void AddItem(BasketItem item)
{ {
BadgeCount++; BadgeCount++;
var basketItem = BasketItems AddBasketItem(item);
.FirstOrDefault(bi => bi.ProductId.Equals(parameter.ProductId,
StringComparison.CurrentCultureIgnoreCase));
basketItem.Quantity++;
RaisePropertyChanged(() => BasketItems); RaisePropertyChanged(() => BasketItems);
ReCalculateTotal();
} }
private void AddBasketItem(BasketItem item) private void AddBasketItem(BasketItem item)

View File

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

View File

@ -86,33 +86,15 @@
<RowDefinition Height="1" /> <RowDefinition Height="1" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<!-- IMAGE --> <!-- IMAGE -->
<ffimageloading:CachedImage <Image
Grid.Column="0" Grid.Column="0"
Grid.Row="0" Grid.Row="0"
Source="{Binding PictureUrl, Converter={StaticResource ImageConverter}}" Source="{Binding PictureUrl, Converter={StaticResource ImageConverter}}"
CacheDuration="30"
CacheType="Disk"
DownsampleToViewSize="True"
HeightRequest="108" HeightRequest="108"
WidthRequest="108" WidthRequest="108"
Aspect="AspectFit" Aspect="AspectFit"
VerticalOptions="Start" VerticalOptions="Start"
Margin="12,0,0,0"> 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>
<Grid <Grid
Grid.Column="1" Grid.Column="1"
Grid.Row="0" Grid.Row="0"

View File

@ -70,33 +70,15 @@
<RowDefinition Height="1" /> <RowDefinition Height="1" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<!-- IMAGE --> <!-- IMAGE -->
<ffimageloading:CachedImage <Image
Grid.Column="0" Grid.Column="0"
Grid.Row="0" Grid.Row="0"
Source="{Binding PictureUrl, Converter={StaticResource ImageConverter}}" Source="{Binding PictureUrl, Converter={StaticResource ImageConverter}}"
CacheDuration="30"
CacheType="Disk"
DownsampleToViewSize="True"
HeightRequest="108" HeightRequest="108"
WidthRequest="108" WidthRequest="108"
Aspect="AspectFit" Aspect="AspectFit"
VerticalOptions="Start" VerticalOptions="Start"
Margin="12,0,0,0"> 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>
<Grid <Grid
Grid.Column="1" Grid.Column="1"
Grid.Row="0" Grid.Row="0"

View File

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