void InitViewBag(Avto model, bool IsPostMethod) { if (IsPostMethod) { var modelAvto = repModelAvto.Get(model.ModelAvtoId); ViewBag.BrandId = new SelectList(GetBrand.Union(repBrand.GetAll()), "Id", "Name", modelAvto.BrandId); ViewBag.ModelAvtoId = new SelectList(GetModelAvto(modelAvto.BrandId), "ModelAvtoId", "ModelName", model.ModelAvtoId); } else { if (model.ModelAvtoId == 0) { ViewBag.BrandId = new SelectList(GetBrand.Union(repBrand.GetAll()), "Id", "Name"); ViewBag.ModelAvtoId = new SelectList(GetModelAvtoNull, "ModelAvtoId", "ModelName"); } else { var modelAvto = repModelAvto.Get(model.ModelAvtoId); ViewBag.BrandId = new SelectList(GetBrand.Union(repBrand.GetAll()), "Id", "Name", modelAvto.BrandId); ViewBag.ModelAvtoId = new SelectList(GetModelAvto(modelAvto.BrandId), "ModelAvtoId", "ModelName", model.ModelAvtoId); } } ViewBag.DriveUnitId = new SelectList(GetDriveUnit.Union(repDriveUnit.GetAll()), "Id", "Name", model.DriveUnitId); ViewBag.AutoBodyId = new SelectList(GetAutoBody.Union(repAutoBody.GetAll()), "Id", "Name", model.AutoBodyId); ViewBag.FuelId = new SelectList(GetFuel.Union(repFuel.GetAll()), "Id", "Name", model.FuelId); ViewBag.KPPId = new SelectList(GetKPP.Union(repKPP.GetAll()), "Id", "Name", model.KPPId); }
public static StatefulComputation <int, int> GetFuelRecurse() => mass => { var fuel = GetFuel()(mass); return((fuel > 0) ? fuel + GetFuelRecurse()(fuel).Value : 0, fuel); };