public CheckContinentViewModel GetCheckContinentsInitialModel() { //setup properties var model = new CheckContinentViewModel(); var selectedCheckContinents = new List <CheckContinent>(); //setup a view model model.AvailableCheckContinents = CheckContinentRepository.GetAll().ToList(); model.SelectedCheckContinents = selectedCheckContinents; return(model); }
public CheckContinentViewModel GetCheckContinentModel(PostedCheckContinents postedCheckContinents) { Array.Clear(GlobVar.postedCheckCon, 0, GlobVar.postedCheckCon.Length); var model = new CheckContinentViewModel(); var selectedCheckContinents = new List <CheckContinent>(); var postedCheckContinentIds = new string[0]; if (postedCheckContinents == null) { postedCheckContinents = new PostedCheckContinents(); } if (postedCheckContinents.CheckContinentIds != null && postedCheckContinents.CheckContinentIds.Any()) { postedCheckContinentIds = postedCheckContinents.CheckContinentIds; GlobVar.postedCheckCon = postedCheckContinents.CheckContinentIds; } // if there are any selected ids saved, create a list of checkcontinents if (postedCheckContinentIds.Any()) { selectedCheckContinents = CheckContinentRepository.GetAll() .Where(x => postedCheckContinentIds.Any(s => x.Id.ToString().Equals(s))) .ToList(); } model.AvailableCheckContinents = CheckContinentRepository.GetAll().ToList(); model.SelectedCheckContinents = selectedCheckContinents; model.PostedCheckContinents = postedCheckContinents; return(model); }