1
Fork 0

fsharp(todolist-api): refactor: changed a few nonsensical names

Signed-off-by: prescientmoon <git@moonythm.dev>
This commit is contained in:
Matei Adriel 2020-01-02 18:13:31 +02:00 committed by prescientmoon
parent 534ee1594a
commit ef078d4e50
Signed by: prescientmoon
SSH key fingerprint: SHA256:UUF9JT2s8Xfyv76b8ZuVL7XrmimH4o49p4b+iexbVH4
2 changed files with 7 additions and 7 deletions

View file

@ -41,7 +41,7 @@ module App =
fun ctx -> async { fun ctx -> async {
let body: Types.TodoDetails = parseJson ctx.request.rawForm let body: Types.TodoDetails = parseJson ctx.request.rawForm
do! Queries.updateTodoById todo body dbContext do! Queries.updateTodo todo body dbContext
return! respondWithTodo todo ctx return! respondWithTodo todo ctx
}) })
@ -50,14 +50,14 @@ module App =
fun ctx -> async { fun ctx -> async {
let body: Types.PartialTodoDetails = parseJson ctx.request.rawForm let body: Types.PartialTodoDetails = parseJson ctx.request.rawForm
do! Queries.patchTodoById todo body dbContext do! Queries.patchTodo todo body dbContext
return! respondWithTodo todo ctx return! respondWithTodo todo ctx
}) })
let deleteTodo = withTodoById (fun (todo, dbContext) -> let deleteTodo = withTodoById (fun (todo, dbContext) ->
fun ctx -> async { fun ctx -> async {
do! Queries.deleteTodoById todo dbContext do! Queries.deleteTodo todo dbContext
return! respondWithTodo todo ctx return! respondWithTodo todo ctx
}) })

View file

@ -85,13 +85,13 @@ module Queries =
} }
|> Seq.toList |> Seq.toList
let updateTodoById (todo: DbTodo) (details: TodoDetails) (ctx: DbContext) = let updateTodo (todo: DbTodo) (details: TodoDetails) (ctx: DbContext) =
todo.Name <- details.name todo.Name <- details.name
todo.Description <- details.description todo.Description <- details.description
ctx.SubmitUpdatesAsync() ctx.SubmitUpdatesAsync()
let patchTodoById (todo: DbTodo) (details: PartialTodoDetails) (ctx: DbContext) = let patchTodo (todo: DbTodo) (details: PartialTodoDetails) (ctx: DbContext) =
Option.iter (fun name -> todo.Name <- name) details.name Option.iter (fun name -> todo.Name <- name) details.name
Option.iter (fun description -> todo.Description <- description) details.description Option.iter (fun description -> todo.Description <- description) details.description
@ -99,7 +99,7 @@ module Queries =
then ctx.SubmitUpdatesAsync() then ctx.SubmitUpdatesAsync()
else Async.result() else Async.result()
let deleteTodoById (todo: DbTodo) (ctx: DbContext) = let deleteTodo (todo: DbTodo) (ctx: DbContext) =
todo.Delete() todo.Delete()
ctx.SubmitUpdatesAsync() ctx.SubmitUpdatesAsync()
@ -108,7 +108,7 @@ module Queries =
async { async {
let todo = ctx.Public.Todos.Create() let todo = ctx.Public.Todos.Create()
do! updateTodoById todo details ctx do! updateTodo todo details ctx
return todo return todo
} }