private IList<SelectListItem> ObtenerModelos(LineaIndexViewModel model) { return _lineasDb.GetById((int)model.LineaID).Modelos_Linea .Select(m => new SelectListItem() { Text = m.Codigo, Value = m.Id.ToString() }).ToList(); }
private bool isModelSelected(LineaIndexViewModel model) { return model.ModeloID != null; }
private bool isOnlyLineaSelected(LineaIndexViewModel model) { return model.ModeloID == null && model.LineaID != null; }
// GET: LineaProduccion public ActionResult Index(LineaIndexViewModel model) { LineaIndexViewModel newModel = new LineaIndexViewModel(); newModel.Lineas = _lineasDb.FindAll().Select(l => new SelectListItem() { Text = l.Nombre_Linea, Value = l.Id.ToString() }).ToList(); newModel.LineaID = model.LineaID; newModel.ModeloID = model.ModeloID; if (isOnlyLineaSelected(model)) { newModel.ModelosLinea = ObtenerModelos(model); } else if (isModelSelected(model)) { newModel.ModelosLinea = ObtenerModelos(model); var modelo = _modelosDb.GetById((int)model.ModeloID); newModel.Modelo = modelo; newModel.TotalCostoDirecto = _fichasDb.CalculateTotalMaterialCost(modelo.Ficha, costoDirecto: true); newModel.TotalCostoIndirecto = _fichasDb.CalculateTotalMaterialCost(modelo.Ficha, costoDirecto: false); } return View(newModel); }