Skip to content

Commit

Permalink
Refactor Equals method and update Restaurants API
Browse files Browse the repository at this point in the history
Refactored the Equals method in the Resturant class to implement IEquatable<Resturant> for better type safety and performance. Removed the GetHashCode method from the Resturant class, which may affect hash-based collections. Updated the host address in Restaurants.http and added two new HTTP GET requests for fetching all restaurants and a specific restaurant by ID.
  • Loading branch information
nahiandev committed Dec 30, 2024
1 parent 8e75d69 commit ea69fa9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
7 changes: 1 addition & 6 deletions src/Domains/Models/Resturant.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class Resturant



public override bool Equals(object to_be_compared)
public bool Equals(Resturant? to_be_compared)
{
if (to_be_compared is Resturant another_resturant)
{
Expand All @@ -27,10 +27,5 @@ public override bool Equals(object to_be_compared)

return false;
}

public override int GetHashCode()
{
return HashCode.Combine(Id, Name, Description, Category, HasDelivery, PhoneNumber, Email);
}
}
}
8 changes: 7 additions & 1 deletion src/Restaurants.http
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
@Restaurants_HostAddress = https://localhost:44369
@Restaurants_HostAddress = https://localhost:7244


GET {{Restaurants_HostAddress}}/api/resturant

###

@id=1
GET {{Restaurants_HostAddress}}/api/Resturant/{{id}}

###

0 comments on commit ea69fa9

Please sign in to comment.