// GET: Admin/FavouriteProperty/Create public async Task <ActionResult> Create() { var model = new FavouritePropertyModel { Favourites = await db.Favourites.ToListAsync(), Propertys = await db.Propertys.ToListAsync() }; return(View(model)); }
public static async Task <FavouritePropertyModel> Convert( this FavouriteProperty favouriteProperty, ApplicationDbContext db, bool addListData = true) { var model = new FavouritePropertyModel { FavouriteId = favouriteProperty.FavouriteId, PropertyId = favouriteProperty.PropertyId, Favourites = addListData ? await db.Favourites.ToListAsync() : null, Propertys = addListData ? await db.Propertys.ToListAsync() : null, FavouriteTitle = (await db.Favourites.FirstOrDefaultAsync( f => f.Id.Equals(favouriteProperty.FavouriteId))).Title, PropertyTitle = (await db.Propertys.FirstOrDefaultAsync(p => p.Id.Equals(favouriteProperty.PropertyId))).Title }; return(model); }