-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Web): ef core / sqlite integration
- Loading branch information
1 parent
83c530e
commit 35a0ba1
Showing
15 changed files
with
355 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -348,3 +348,5 @@ MigrationBackup/ | |
|
||
# Ionide (cross platform F# VS Code tools) working folder | ||
.ionide/ | ||
|
||
**/App_Data/FShopOnWeb* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,55 @@ | ||
namespace Microsoft.eShopWeb.Web.Home | ||
|
||
open Microsoft.eShopWeb.Web.Domain | ||
open Falco | ||
open Falco.Markup.Attr | ||
open Falco.Markup.Elem | ||
open Microsoft.eShopWeb.Web | ||
open Microsoft.eShopWeb.Web.Home | ||
open Microsoft.eShopWeb.Web.Persistence | ||
open System.Linq | ||
open Microsoft.EntityFrameworkCore | ||
|
||
module HomePage = | ||
type Props = | ||
{ FiltersProps: CatalogFiltersComponent.Props | ||
GridProps: CatalogGridComponent.Props | ||
PagerProps: CatalogPagerComponent.Props } | ||
|
||
module private Template = | ||
let metadata: PublicLayout.HeadMetadata = { Title = "Home"; Description = "" } | ||
|
||
let head = PublicLayout.head metadata | ||
|
||
let body = | ||
let body props = | ||
PublicLayout.body | ||
[ CatalogFiltersComponent.cmpt | ||
[ CatalogFiltersComponent.cmpt props.FiltersProps | ||
div | ||
[ class' "container" ] | ||
[ CatalogPagerComponent.cmpt | ||
CatalogGridComponent.cmpt | ||
CatalogPagerComponent.cmpt ] ] | ||
[ CatalogPagerComponent.cmpt props.PagerProps | ||
CatalogGridComponent.cmpt props.GridProps | ||
CatalogPagerComponent.cmpt props.PagerProps ] ] | ||
|
||
let page props = PublicLayout.layout head (body props) | ||
|
||
let handler: HttpHandler = | ||
Services.inject<ShopContext> (fun context -> | ||
let dbItems = | ||
context | ||
.CatalogItems | ||
.Include(fun i -> i.CatalogBrand) | ||
.Include(fun i -> i.CatalogType) | ||
.ToList() | ||
|
||
let items = List.ofSeq (dbItems) | ||
let brands = List.map (fun i -> i.CatalogBrand.Name) items |> List.distinct | ||
let types = List.map (fun i -> i.CatalogType.Name) items |> List.distinct | ||
|
||
let page = PublicLayout.layout head body | ||
let props = | ||
{ FiltersProps = { Types = types; Brands = brands } | ||
GridProps = { CatalogItems = items } | ||
PagerProps = | ||
{ ItemsCount = items.Length | ||
CurrentPage = 1 } } | ||
|
||
let handler: HttpHandler = Response.ofHtml Template.page | ||
Response.ofHtml (Template.page props)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.