// GET: Admin/SubscriptionVehicle/Create public async Task <ActionResult> Create() { var model = new SubscriptionVehicleModel { Subscriptions = await db.Subscriptions.ToListAsync(), Vehicles = await db.Vehicles.ToListAsync(), }; return(View(model)); }
public static async Task <SubscriptionVehicleModel> Convert( this SubscriptionVehicle subscriptionVehicle, ApplicationDbContext db, bool addListData = true) { var model = new SubscriptionVehicleModel { SubscriptionId = subscriptionVehicle.SubscriptionId, VehicleId = subscriptionVehicle.VehicleId, Subscriptions = addListData ? await db.Subscriptions.ToListAsync() : null, Vehicles = addListData ? await db.Vehicles.ToListAsync() : null, SubscriptionTitle = (await db.Subscriptions.FirstOrDefaultAsync(s => s.Id.Equals(subscriptionVehicle.SubscriptionId))).Title, VehicleTitle = (await db.Vehicles.FirstOrDefaultAsync(v => v.Id.Equals(subscriptionVehicle.VehicleId))).Title }; return(model); }