I have a best practices question.
I have a method BuildTourTime
that takes a DateTime and a string that represents the time.
internal DateTime BuildDateTime(DateTime date, string time)
{
return date.Add(TimeSpan.Parse(time));
}
I'll be using this in multiple locations. Currently it is being used in another class
private IEnumerable<Tour> BuildTours(Response Data)
{
//Tour tour = new Tour();
List<Tour> tours = new List<Tour>();
foreach(Events ivEvents in Data.response.events)
{
bool isCancelled = true; //Replace this with logic
tours.Add(new Tour(ivEvents.Id,Data.response.ID,Data.response.Title,BuildDateTime(ivEvents.Date,ivEvent.Start),isCancelled,ivEvents.Quantity-ivEvents.Remaining).);
}
return tours;
}
I currently have the Tour class without having a parameterless constructor. I have a few options here as far as i can tell. Declare the BuildDateTime static. Or add a parameterless constructor for Tour. Or Create a helper class and put BuildDateTime. Is this a good place to be using a static method? That is what i am leaning towards.
Edit: Why the downvotes? The link posted(which i read before posting this question) does not answer my question. My question shows that i have investigated options i could use and I have asked an exact question, as well as providing relative code.