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

@ -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)

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">

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"

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"

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