Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add style cop and xml comments #1

Merged
merged 2 commits into from
Nov 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion MauiStoreApp.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.7.34024.191
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MauiStoreApp", "MauiStoreApp\MauiStoreApp.csproj", "{9D34B1B5-C517-43AD-A59C-D57426129FD8}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MauiStoreApp", "MauiStoreApp\MauiStoreApp.csproj", "{9D34B1B5-C517-43AD-A59C-D57426129FD8}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{6982EDC3-5252-4F81-8E3F-485E4134D54B}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
16 changes: 16 additions & 0 deletions MauiStoreApp/MauiStoreApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,27 @@
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
</ItemGroup>

<ItemGroup>
<None Remove="stylecop.json" />
</ItemGroup>

<ItemGroup>
<AdditionalFiles Include="stylecop.json" />
</ItemGroup>

<ItemGroup>
<None Include="..\.editorconfig" Link=".editorconfig" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="CommunityToolkit.Maui" Version="5.3.0" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="7.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
Expand Down
35 changes: 34 additions & 1 deletion MauiStoreApp/Models/Address.cs
Original file line number Diff line number Diff line change
@@ -1,28 +1,61 @@
using System.Text.Json.Serialization;
// -----------------------------------------------------------------------
// <copyright file="Address.cs" company="Kvesic, Matkovic, FSRE">
// Copyright (c) Kvesic, Matkovic, FSRE. All rights reserved.
// </copyright>
// -----------------------------------------------------------------------

using System.Text.Json.Serialization;

namespace MauiStoreApp.Models
{
/// <summary>
/// Represents an address.
/// </summary>
public class Address
{
/// <summary>
/// Gets or sets the geolocation of the address.
/// </summary>
[JsonPropertyName("geolocation")]
public Geolocation Geolocation { get; set; }

/// <summary>
/// Gets or sets the city of the address.
/// </summary>
[JsonPropertyName("city")]
public string City { get; set; }

/// <summary>
/// Gets or sets the street of the address.
/// </summary>
[JsonPropertyName("street")]
public string Street { get; set; }

/// <summary>
/// Gets or sets the number of the address.
/// </summary>
[JsonPropertyName("number")]
public int Number { get; set; }

/// <summary>
/// Gets or sets the zipcode of the address.
/// </summary>
[JsonPropertyName("zipcode")]
public string Zipcode { get; set; }

/// <summary>
/// Gets the city with the first letter capitalized.
/// </summary>
public string CityCapitalized => $"{City?.ToUpper()[0]}{City?.ToLower()[1..]}";

/// <summary>
/// Gets the city and zipcode concatenated.
/// </summary>
public string CityAndZipcode => $"{CityCapitalized} {Zipcode}";

/// <summary>
/// Gets the full street with the first letter capitalized followed by the street number.
/// </summary>
public string FullStreet => $"{Street?.ToUpper()[0]}{Street?.ToLower()[1..]} {Number}";
}
}
26 changes: 25 additions & 1 deletion MauiStoreApp/Models/Cart.cs
Original file line number Diff line number Diff line change
@@ -1,21 +1,45 @@
using System.Text.Json.Serialization;
// -----------------------------------------------------------------------
// <copyright file="Cart.cs" company="Kvesic, Matkovic, FSRE">
// Copyright (c) Kvesic, Matkovic, FSRE. All rights reserved.
// </copyright>
// -----------------------------------------------------------------------

using System.Text.Json.Serialization;

namespace MauiStoreApp.Models
{
/// <summary>
/// Represents a shopping cart.
/// </summary>
public class Cart
{
/// <summary>
/// Gets or sets the unique identifier of the cart.
/// </summary>
[JsonPropertyName("id")]
public int Id { get; set; }

/// <summary>
/// Gets or sets the unique identifier of the user to whom the cart belongs.
/// </summary>
[JsonPropertyName("userId")]
public int UserId { get; set; }

/// <summary>
/// Gets or sets the date the cart was created or last updated.
/// </summary>
[JsonPropertyName("date")]
public DateTime Date { get; set; }

/// <summary>
/// Gets or sets the list of products in the cart.
/// </summary>
[JsonPropertyName("products")]
public List<CartProduct> Products { get; set; }

/// <summary>
/// Gets or sets the version of the cart.
/// </summary>
[JsonPropertyName("__v")]
public int Version { get; set; }
}
Expand Down
24 changes: 23 additions & 1 deletion MauiStoreApp/Models/CartItemDetail.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
using System.ComponentModel;
// -----------------------------------------------------------------------
// <copyright file="CartItemDetail.cs" company="Kvesic, Matkovic, FSRE">
// Copyright (c) Kvesic, Matkovic, FSRE. All rights reserved.
// </copyright>
// -----------------------------------------------------------------------

using System.ComponentModel;

namespace MauiStoreApp.Models
{
/// <summary>
/// Represents the details of an item in the shopping cart, including the product and quantity.
/// </summary>
public class CartItemDetail : INotifyPropertyChanged
{
private Product _product;
private int _quantity;

/// <summary>
/// Gets or sets the product in the cart item.
/// </summary>
public Product Product
{
get => _product;
Expand All @@ -20,6 +32,9 @@ public Product Product
}
}

/// <summary>
/// Gets or sets the quantity of the product in the cart item.
/// </summary>
public int Quantity
{
get => _quantity;
Expand All @@ -33,8 +48,15 @@ public int Quantity
}
}

/// <summary>
/// Occurs when a property value changes.
/// </summary>
public event PropertyChangedEventHandler PropertyChanged;

/// <summary>
/// Raises the PropertyChanged event for the specified property.
/// </summary>
/// <param name="propertyName">The name of the property that has changed.</param>
protected virtual void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
Expand Down
17 changes: 16 additions & 1 deletion MauiStoreApp/Models/CartProduct.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
using System.Text.Json.Serialization;
// -----------------------------------------------------------------------
// <copyright file="CartProduct.cs" company="Kvesic, Matkovic, FSRE">
// Copyright (c) Kvesic, Matkovic, FSRE. All rights reserved.
// </copyright>
// -----------------------------------------------------------------------

using System.Text.Json.Serialization;

namespace MauiStoreApp.Models
{
/// <summary>
/// Represents a product in the shopping cart, including the product ID and quantity.
/// </summary>
public class CartProduct
{
/// <summary>
/// Gets or sets the ID of the product.
/// </summary>
[JsonPropertyName("productId")]
public int ProductId { get; set; }

/// <summary>
/// Gets or sets the quantity of the product in the cart.
/// </summary>
[JsonPropertyName("quantity")]
public int Quantity { get; set; }
}
Expand Down
19 changes: 17 additions & 2 deletions MauiStoreApp/Models/Category.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
namespace MauiStoreApp.Models
// -----------------------------------------------------------------------
// <copyright file="Category.cs" company="Kvesic, Matkovic, FSRE">
// Copyright (c) Kvesic, Matkovic, FSRE. All rights reserved.
// </copyright>
// -----------------------------------------------------------------------

namespace MauiStoreApp.Models
{
/// <summary>
/// Represents a product category with a name and associated image.
/// </summary>
public class Category
{
/// <summary>
/// Gets or sets the name of the category.
/// </summary>
public string Name { get; set; }

/// <summary>
/// Gets the filename of the image associated with the category.
/// </summary>
public string ImageName
{
get
Expand All @@ -13,7 +28,7 @@ public string ImageName
return null;
}

string formattedName = Name.Replace(" ", "_").Replace("'", "").ToLower();
string formattedName = Name.Replace(" ", "_").Replace("'", string.Empty).ToLower();
return formattedName + ".jpg";
}
}
Expand Down
17 changes: 16 additions & 1 deletion MauiStoreApp/Models/Geolocation.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
using System.Text.Json.Serialization;
// -----------------------------------------------------------------------
// <copyright file="Geolocation.cs" company="Kvesic, Matkovic, FSRE">
// Copyright (c) Kvesic, Matkovic, FSRE. All rights reserved.
// </copyright>
// -----------------------------------------------------------------------

using System.Text.Json.Serialization;

namespace MauiStoreApp.Models
{
/// <summary>
/// Represents a geographical location with latitude and longitude.
/// </summary>
public class Geolocation
{
/// <summary>
/// Gets or sets the latitude of the geographical location.
/// </summary>
[JsonPropertyName("lat")]
public string Lat { get; set; }

/// <summary>
/// Gets or sets the longitude of the geographical location.
/// </summary>
[JsonPropertyName("long")]
public string Long { get; set; }
}
Expand Down
19 changes: 17 additions & 2 deletions MauiStoreApp/Models/LoginRequest.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
using System.Text.Json.Serialization;
// -----------------------------------------------------------------------
// <copyright file="LoginRequest.cs" company="Kvesic, Matkovic, FSRE">
// Copyright (c) Kvesic, Matkovic, FSRE. All rights reserved.
// </copyright>
// -----------------------------------------------------------------------

using System.Text.Json.Serialization;

namespace MauiStoreApp.Models
{
/// <summary>
/// Represents a request for user login with username and password.
/// </summary>
public class LoginRequest
{
{
/// <summary>
/// Gets or sets the username for login.
/// </summary>
[JsonPropertyName("username")]
public string Username { get; set; }

/// <summary>
/// Gets or sets the password for login.
/// </summary>
[JsonPropertyName("password")]
public string Password { get; set; }
}
Expand Down
18 changes: 17 additions & 1 deletion MauiStoreApp/Models/LoginResponse.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,28 @@
using System.Text.Json.Serialization;
// -----------------------------------------------------------------------
// <copyright file="LoginResponse.cs" company="Kvesic, Matkovic, FSRE">
// Copyright (c) Kvesic, Matkovic, FSRE. All rights reserved.
// </copyright>
// -----------------------------------------------------------------------

using System.Text.Json.Serialization;

namespace MauiStoreApp.Models
{
/// <summary>
/// Represents the response from a login attempt, including an authentication token and user ID.
/// </summary>
public class LoginResponse
{
/// <summary>
/// Gets or sets the authentication token for the user.
/// </summary>
[JsonPropertyName("token")]
public string Token { get; set; }

/// <summary>
/// Gets or sets the user ID.
/// </summary>
[JsonPropertyName("userId")]
public int UserId { get; set; }
}
}
17 changes: 16 additions & 1 deletion MauiStoreApp/Models/Name.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
using System.Text.Json.Serialization;
// -----------------------------------------------------------------------
// <copyright file="Name.cs" company="Kvesic, Matkovic, FSRE">
// Copyright (c) Kvesic, Matkovic, FSRE. All rights reserved.
// </copyright>
// -----------------------------------------------------------------------

using System.Text.Json.Serialization;

namespace MauiStoreApp.Models
{
/// <summary>
/// Represents a person's first and last name.
/// </summary>
public class Name
{
/// <summary>
/// Gets or sets the first name of the person.
/// </summary>
[JsonPropertyName("firstname")]
public string Firstname { get; set; }

/// <summary>
/// Gets or sets the last name of the person.
/// </summary>
[JsonPropertyName("lastname")]
public string Lastname { get; set; }
}
Expand Down