Skip to content

Commit c452088

Browse files
author
Carlos Cañizares Estévez
committed
2 parents 6cff3aa + b9223b3 commit c452088

41 files changed

Lines changed: 697 additions & 309 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/Mobile/eShopOnContainers/eShopOnContainers.Core/App.xaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,13 @@
9898
WinPhone="48"/>
9999

100100
<!-- CONVERTERS -->
101-
<converters:ToUpperConverter x:Key="ToUpperConverter" />
101+
<converters:CountToBoolConverter x:Key="CountToBoolConverter" />
102102
<converters:DatetimeConverter x:Key="DatetimeConverter" />
103+
<converters:ImageConverter x:Key="ImageConverter" />
103104
<converters:ItemTappedEventArgsConverter x:Key="ItemTappedEventArgsConverter" />
104-
105+
<converters:InverseCountToBoolConverter x:Key="InverseCountToBoolConverter" />
106+
<converters:ToUpperConverter x:Key="ToUpperConverter" />
107+
105108
<!-- STYLES -->
106109
<Style x:Key="EntryStyle"
107110
TargetType="{x:Type Entry}">
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using System;
2+
using System.Globalization;
3+
using Xamarin.Forms;
4+
5+
namespace eShopOnContainers.Core.Converters
6+
{
7+
public class CountToBoolConverter : IValueConverter
8+
{
9+
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
10+
{
11+
if (value is int)
12+
{
13+
int count = System.Convert.ToInt32(value);
14+
15+
return count > 0;
16+
}
17+
18+
return value;
19+
}
20+
21+
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
22+
{
23+
throw new NotImplementedException();
24+
}
25+
}
26+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using System;
2+
using System.Globalization;
3+
using Xamarin.Forms;
4+
5+
namespace eShopOnContainers.Core.Converters
6+
{
7+
public class ImageConverter : IValueConverter
8+
{
9+
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
10+
{
11+
if (value == null)
12+
return string.Empty;
13+
14+
return value;
15+
}
16+
17+
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
18+
{
19+
throw new NotImplementedException();
20+
}
21+
}
22+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using System;
2+
using System.Globalization;
3+
using Xamarin.Forms;
4+
5+
namespace eShopOnContainers.Core.Converters
6+
{
7+
public class InverseCountToBoolConverter : IValueConverter
8+
{
9+
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
10+
{
11+
if (value is int)
12+
{
13+
int count = System.Convert.ToInt32(value);
14+
15+
return count == 0;
16+
}
17+
18+
return value;
19+
}
20+
21+
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
22+
{
23+
throw new NotImplementedException();
24+
}
25+
}
26+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace eShopOnContainers.Core
2+
{
3+
public static class GlobalSetting
4+
{
5+
public const string RegisterWebsite = "http://104.40.62.65/Account/Register";
6+
}
7+
}
Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1-
using System;
2-
3-
namespace eShopOnContainers.Core.Models.Catalog
1+
namespace eShopOnContainers.Core.Models.Catalog
42
{
53
public class CatalogItem
64
{
7-
public int Id { get; set; }
5+
public string Id { get; set; }
86
public string Name { get; set; }
97
public string Description { get; set; }
108
public decimal Price { get; set; }
11-
public string Image { get; set; }
9+
public string PictureUri { get; set; }
10+
public int CatalogBrandId { get; set; }
11+
public string CatalogBrand { get; set; }
12+
public int CatalogTypeId { get; set; }
13+
public string CatalogType { get; set; }
14+
1215
}
1316
}

src/Mobile/eShopOnContainers/eShopOnContainers.Core/Models/Orders/OrderItem.cs

Lines changed: 81 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,90 @@
1-
using System;
1+
using eShopOnContainers.ViewModels.Base;
2+
using System;
23

34
namespace eShopOnContainers.Core.Models.Orders
45
{
5-
public class OrderItem
6+
public class OrderItem : ExtendedBindableObject
67
{
7-
public int ProductId { get; set; }
8-
public Guid OrderId { get; set; }
9-
public string ProductName { get; set; }
10-
public decimal UnitPrice { get; set; }
11-
public int Quantity { get; set; }
12-
public decimal Discount { get; set; }
8+
private string _productImage;
9+
private int _productId;
10+
private Guid _orderId;
11+
private string _productName;
12+
private decimal _unitPrice;
13+
private int _quantity;
14+
private decimal _discount;
15+
16+
public int ProductId
17+
{
18+
get { return _productId; }
19+
set
20+
{
21+
_productId = value;
22+
RaisePropertyChanged(() => ProductId);
23+
}
24+
}
25+
26+
public Guid OrderId
27+
{
28+
get { return _orderId; }
29+
set
30+
{
31+
_orderId = value;
32+
RaisePropertyChanged(() => OrderId);
33+
}
34+
}
35+
36+
public string ProductName
37+
{
38+
get { return _productName; }
39+
set
40+
{
41+
_productName = value;
42+
RaisePropertyChanged(() => ProductName);
43+
}
44+
}
45+
46+
public decimal UnitPrice
47+
{
48+
get { return _unitPrice; }
49+
set
50+
{
51+
_unitPrice = value;
52+
RaisePropertyChanged(() => UnitPrice);
53+
}
54+
}
55+
56+
public int Quantity
57+
{
58+
get { return _quantity; }
59+
set
60+
{
61+
_quantity = value;
62+
RaisePropertyChanged(() => Quantity);
63+
}
64+
}
65+
66+
public decimal Discount
67+
{
68+
get { return _discount; }
69+
set
70+
{
71+
_discount = value;
72+
RaisePropertyChanged(() => Discount);
73+
}
74+
}
75+
1376
public decimal Total { get { return Quantity * UnitPrice; } }
1477

78+
public string ProductImage
79+
{
80+
get { return _productImage; }
81+
set
82+
{
83+
_productImage = value;
84+
RaisePropertyChanged(() => ProductImage);
85+
}
86+
}
87+
1588
public override string ToString()
1689
{
1790
return String.Format("Product Id: {0}, Quantity: {1}", ProductId, Quantity);
Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,33 @@
11
using eShopOnContainers.Core.Models.Catalog;
22
using System;
33
using System.Collections.ObjectModel;
4+
using System.Linq;
45
using System.Threading.Tasks;
56
using Xamarin.Forms;
67

78
namespace eShopOnContainers.Core.Services.Catalog
89
{
910
public class CatalogMockService : ICatalogService
1011
{
11-
public async Task<ObservableCollection<CatalogItem>> GetProductsAsync()
12+
private ObservableCollection<CatalogItem> MockCatalog = new ObservableCollection<CatalogItem>
13+
{
14+
new CatalogItem { Id = "1", PictureUri = Device.OS != TargetPlatform.Windows? "fake_product_01" : "Assets/fake_product_01.png", Name = ".NET Bot Blue Sweatshirt (M)", Price = 19.50M },
15+
new CatalogItem { Id = "2", PictureUri = Device.OS != TargetPlatform.Windows? "fake_product_02": "Assets/fake_product_02.png", Name = ".NET Bot Purple Sweatshirt (M)", Price = 19.50M },
16+
new CatalogItem { Id = "3", PictureUri = Device.OS != TargetPlatform.Windows? "fake_product_03": "Assets/fake_product_03.png", Name = ".NET Bot Black Sweatshirt (M)", Price = 19.95M }
17+
};
18+
19+
public async Task<ObservableCollection<CatalogItem>> GetCatalogAsync()
20+
{
21+
await Task.Delay(500);
22+
23+
return MockCatalog;
24+
}
25+
26+
public async Task<CatalogItem> GetCatalogItemAsync(string id)
1227
{
1328
await Task.Delay(500);
1429

15-
return new ObservableCollection<CatalogItem>
16-
{
17-
new CatalogItem { Id = 1, Image = Device.OS != TargetPlatform.Windows ? "fake_product_01" : "Assets/fake_product_01.png", Name = ".NET Bot Blue Sweatshirt (M)", Price = 19.50M },
18-
new CatalogItem { Id = 2, Image = Device.OS != TargetPlatform.Windows ? "fake_product_02": "Assets/fake_product_02.png", Name = ".NET Bot Purple Sweatshirt (M)", Price = 19.50M },
19-
new CatalogItem { Id = 3, Image = Device.OS != TargetPlatform.Windows ? "fake_product_03": "Assets/fake_product_03.png", Name = ".NET Bot Black Sweatshirt (M)", Price = 19.95M }
20-
};
30+
return MockCatalog.FirstOrDefault(c => c.Id == id);
2131
}
2232
}
2333
}

src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Catalog/ICatalogService.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ namespace eShopOnContainers.Core.Services.Catalog
66
{
77
public interface ICatalogService
88
{
9-
Task<ObservableCollection<CatalogItem>> GetProductsAsync();
9+
Task<ObservableCollection<CatalogItem>> GetCatalogAsync();
10+
Task<CatalogItem> GetCatalogItemAsync(string id);
1011
}
1112
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace eShopOnContainers.Core.Services.OpenUrl
2+
{
3+
public interface IOpenUrlService
4+
{
5+
void OpenUrl(string url);
6+
}
7+
}

0 commit comments

Comments
 (0)