public static ReturnSelectList GetList(string name, string display, CarViewModel model) { var result = new ReturnSelectList(); switch (name) { case "Marks": result.List.Add(new KVPBase { Name = "Выберите \"Марку\"", id = 0 }); result.List.AddRange(model.Marks); result.Name = model.Mark; break; case "Models": if (string.IsNullOrEmpty(model.Model)) { break; } result.List.Add(new KVPBase { Name = "Выберите \"Модель\"", id = 0 }); result.List.AddRange(model.Models); result.Name = model.Model; break; case "BodyTypes": if (string.IsNullOrEmpty(model.BodyType)) { break; } result.List.Add(new KVPBase { Name = "Выберите \"Тип кузова\"", id = 0 }); result.List.AddRange(model.BodyTypes); result.Name = model.BodyType; break; case "EngineTypes": if (string.IsNullOrEmpty(model.EngineType)) { break; } result.List.Add(new KVPBase { Name = "Выберите \"Тип двигателя\"", id = 0 }); result.List.AddRange(model.EngineTypes); result.Name = model.EngineType; break; case "EngineVolumes": if (string.IsNullOrEmpty(model.EngineVolume)) { break; } result.List.Add(new KVPBase { Name = "Выберите \"Объем двигателя\"", id = 0 }); result.List.AddRange(model.EngineVolumes); result.Name = model.EngineVolume; break; case "TransTypes": if (string.IsNullOrEmpty(model.TransType)) { break; } result.List.Add(new KVPBase { Name = "Выберите \"Тип КПП\"", id = 0 }); result.List.AddRange(model.TransTypes); result.Name = model.TransType; break; } return(result); }
public JsonResult ChangeSelectList(string name, string data) { var model = new ReturnSelectList(); var indx = 0; if (!int.TryParse(data, out indx) || indx == 0) { return(Json(model)); } switch (name) { case "GetMark": model.Name = "Car_Mark"; model.List.Add(new KVPBase { Name = "Выберите \"Марку\"", id = 0 }); //TODO Get Models model.List.AddRange(_storage.GetMarks()); break; case "Car.Mark": model.Name = "Car_Model"; model.List.Add(new KVPBase { Name = "Выберите \"Модель\"", id = 0 }); //TODO Get Models model.List.AddRange(_storage.GetModels(indx)); break; case "Car.Model": model.Name = "Car_BodyType"; model.List.Add(new KVPBase { Name = "Выберите \"Тип кузова\"", id = 0 }); //TODO Get Bodys model.List.AddRange(_storage.GetBodyTypes(indx)); break; case "Car.BodyType": model.Name = "Car_EngineType"; model.List.Add(new KVPBase { Name = "Выберите \"Тип двигателя\"", id = 0 }); //TODO Get EngineTypes model.List.AddRange(_storage.GetEngineTypes(indx)); break; case "Car.EngineType": model.Name = "Car_EngineVolume"; model.List.Add(new KVPBase { Name = "Выберите \"Объем двигателя\"", id = 0 }); //TODO Get EngineVolumes model.List.AddRange(_storage.GetEngineVolumes(indx)); break; case "Car.EngineVolume": model.Name = "Car_TransType"; model.List.Add(new KVPBase { Name = "Выберите \"Тип КПП\"", id = 0 }); //TODO Get TransTypes model.List.AddRange(_storage.GetTransTypes(indx)); break; } return(Json(model)); }