public DayOfWeekSelectedViewModel PopulateDaysOfWeekSelections(string daysofweekstr) { DayOfWeekSelectedViewModel days = new DayOfWeekSelectedViewModel() { Monday = false, Tuesday = false, Wednesday = false, Thursday = false, Friday = false, Saturday = false, Sunday = false }; if (daysofweekstr.Length < 7) { return(days); } for (int i = 0; i < daysofweekstr.Length; i++) { if ((daysofweekstr[i] == '1') && (i == 0)) { days.Monday = true; } if ((daysofweekstr[i] == '1') && (i == 1)) { days.Tuesday = true; } if ((daysofweekstr[i] == '1') && (i == 2)) { days.Wednesday = true; } if ((daysofweekstr[i] == '1') && (i == 3)) { days.Thursday = true; } if ((daysofweekstr[i] == '1') && (i == 4)) { days.Friday = true; } if ((daysofweekstr[i] == '1') && (i == 5)) { days.Saturday = true; } if ((daysofweekstr[i] == '1') && (i == 6)) { days.Sunday = true; } } return(days); }
public string SetDaysOfWeekTextFromDaysOfWeekSelections(DayOfWeekSelectedViewModel daysofweekmodel) { if (daysofweekmodel == null) { return("0000000"); } string tempstr = ""; if (daysofweekmodel.Monday) { tempstr = tempstr + "1"; } else { tempstr = tempstr + "0"; } if (daysofweekmodel.Tuesday) { tempstr = tempstr + "1"; } else { tempstr = tempstr + "0"; } if (daysofweekmodel.Wednesday) { tempstr = tempstr + "1"; } else { tempstr = tempstr + "0"; } if (daysofweekmodel.Thursday) { tempstr = tempstr + "1"; } else { tempstr = tempstr + "0"; } if (daysofweekmodel.Friday) { tempstr = tempstr + "1"; } else { tempstr = tempstr + "0"; } if (daysofweekmodel.Saturday) { tempstr = tempstr + "1"; } else { tempstr = tempstr + "0"; } if (daysofweekmodel.Sunday) { tempstr = tempstr + "1"; } else { tempstr = tempstr + "0"; } return(tempstr); }