fix code security issues (sonar)
continuous-integration/drone/push Build is passing Details

pull/24/head
Alexandre AGOSTINHO 2 years ago
parent 7d6cf0bb56
commit e3dbd2ab17

@ -59,6 +59,13 @@ namespace Model
return Order.Equals(other.Order) && Description.Equals(other.Description);
}
public override bool Equals(object? obj)
{
var item = obj as PreparationStep;
if (item == null) return false;
return Equals(obj);
}
public override int GetHashCode()
{
return Order.GetHashCode() + Description.GetHashCode();

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Security.Cryptography;
using System.Text;
namespace Model
@ -54,8 +55,14 @@ namespace Model
{
Title = title;
PreparationSteps = new List<PreparationStep>(preparationSteps);
if (id == null) Id = new Random().Next();
if (id == null)
{
var randomGenerator = RandomNumberGenerator.Create();
byte[] data = new byte[16];
randomGenerator.GetBytes(data);
Id = Math.Abs(BitConverter.ToInt16(data));
}
else Id = (int)id;
}
#endregion
@ -68,6 +75,13 @@ namespace Model
return Title.Equals(other.Title) && PreparationSteps.Equals(other.PreparationSteps);
}
public override bool Equals(object? obj)
{
var item = obj as Recipe;
if (item == null) return false;
return Equals(obj);
}
public override int GetHashCode()
{
return Id.GetHashCode();

@ -128,6 +128,13 @@ namespace Model
return _description.Equals(other.Description) && _recipes.Equals(other._recipes);
}
public override bool Equals(object? obj)
{
var item = obj as RecipeCollection;
if (item == null) return false;
return Equals(obj);
}
public override int GetHashCode()
{
return _recipes.GetHashCode();

Loading…
Cancel
Save