Exemplo n.º 1
0
        // 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));
        }
Exemplo n.º 2
0
        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);
        }