Change one of the contructors as shown below from projectId to ID (The middle one)
Then over load the Update Category as shown below the previously stated:
With the following:
Category
.GetCategoryByCategoryId(Id)
Category
.GetCategoryByCategoryId(original_Id);
public static bool UpdateCategory(string Abbreviation, int original_Id, decimal EstimateDuration, string Name/*, int id*/)public static bool UpdateCategory(string Abbreviation, decimal EstimateDuration, string Name, int Id)
Do the same for Delete:
/*** CONSTRUCTOR ***/public Category(string name, int projectId): this(string.Empty, DefaultValues.GetDurationMinValue(), DefaultValues.GetCategoryIdMinValue(), DefaultValues.GetDurationMinValue(), name, projectId) {
}
public Category(string abbreviation, decimal estimateDuration, string name, int Id): this(abbreviation, DefaultValues.GetDurationMinValue(), DefaultValues.GetCategoryIdMinValue(), estimateDuration, name, Id) {
}
public Category(string abbreviation, decimal actualDuration, int id, decimal estimateDuration, string name, int projectId) {
if (String.IsNullOrEmpty(name))throw (new NullReferenceException("name"));
if (projectId <= DefaultValues.GetProjectIdMinValue())throw (new ArgumentOutOfRangeException("projectId"));
_Abbreviation = abbreviation;
_ActualDuration = actualDuration;
_Id = id;
_EstimateDuration = estimateDuration;
_Name = name;
_ProjectId = projectId;
}
______________________________________________________________________________________________________
public static bool UpdateCategory(string Abbreviation, int original_Id, decimal EstimateDuration, string Name/*, int id*/) {
if (String.IsNullOrEmpty(Name))throw (new NullReferenceException("Name"));
Category updateCategory = Category.GetCategoryByCategoryId(original_Id);if (updateCategory != null) {
updateCategory.Abbreviation = Abbreviation;
updateCategory.EstimateDuration = EstimateDuration;
updateCategory.Name = Name;
return (updateCategory.Save());
}
elsereturn false;
}
public static bool UpdateCategory(string Abbreviation, decimal EstimateDuration, string Name, int Id)
{
if (String.IsNullOrEmpty(Name))throw (new NullReferenceException("Name"));
Category updateCategory = Category.GetCategoryByCategoryId(Id);if (updateCategory != null)
{
updateCategory.Abbreviation = Abbreviation;
updateCategory.EstimateDuration = EstimateDuration;
updateCategory.Name = Name;
return (updateCategory.Save());
}
elsereturn false;
}