Changes un Basket logic to adapt to websites logic
This commit is contained in:
parent
4d58ee27a9
commit
5f32ca1947
@ -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)
|
||||
|
@ -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">
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
@ -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…
x
Reference in New Issue
Block a user