I created this sample and wanted any advice on how to make this code; cleaner, more effective, just overall better! I am collecting the days data from the NegativeScheduleSentence model and ScheduleSentencePart model and removing the model from the concepts object. only to have to re-add them back in using the days object from both models. Any help would be great.
sample working https://dotnetfiddle.net/5jA7xh
if (concepts.NegativeScheduleSentencePartModel.Count() > 0 &&
concepts.ScheduleSentencePartModel.Count() > 0)
{
var conceptsNegativeScheduleCalendarDays =
concepts.NegativeScheduleSentencePartModel.Select(x => x.Days).ToList();
var PositiveandNegativeDays = new List<int>();
for (int i = 0; i < conceptsNegativeScheduleCalendarDays.Count; i++)
{
foreach (int day in conceptsNegativeScheduleCalendarDays[i])
{
Console.WriteLine(day);
PositiveandNegativeDays.Add(day);
}
}
var conceptscheduleCalendarDays = concepts.ScheduleSentencePartModel
.Select(x => x.Days).ToList();
for (int i = 0; i < conceptscheduleCalendarDays.Count; i++)
{
foreach (int day in conceptscheduleCalendarDays[i])
{
Console.WriteLine(day);
PositiveandNegativeDays.Add(day);
}
}
concepts.ScheduleSentencePartModel
.RemoveRange(0, ScheduleSentencePartModel.Count);
concepts.NegativeScheduleSentencePartModel
.RemoveRange(0, conceptsNegativeScheduleCalendarDays.Count);
var PositiveandNegativeScheduleSentencePartModel =
new List<ScheduleSentencePartModel>();
ScheduleSentencePartModel.Add(
new ScheduleSentencePartModel() {
Days = PositiveandNegativeDays, Isvalid = true });
concepts.ScheduleSentencePartModel = ScheduleSentencePartModel;
}