postModifySupplierR :: SupplierId -> Handler Html
postModifySupplierR sId = do
  mSup <- runDB $ get sId
  case mSup of
    Just sup -> do
      ((res, _), _) <- runFormPost
        $ renderBootstrap3 BootstrapBasicForm
        $ modifySupplierForm sup
      case res of
        FormSuccess msup -> do
          runDB $ update sId
            [ SupplierIdent =. supConfIdent msup
            , SupplierAddress =. supConfAddr msup
            , SupplierTel =. supConfTel msup
            , SupplierEmail =. supConfEmail msup
            , SupplierCustomerId =. supConfCustomerId msup
            , SupplierAvatar =. supConfAvatar msup
            ]
          setMessageI MsgSupplierEdited
          redirect SupplierR
        _ -> do
          setMessageI MsgSupplierNotEdited
          redirect SupplierR
    Nothing -> do
      setMessageI MsgSupplierUnknown
      redirect SupplierR
postModifySupplierR :: SupplierId -> Handler Html
postModifySupplierR sId = do
  mSup <- runDB $ get sId
  case mSup of
    Just sup -> do
      ((res, _), _) <- runFormPost
        $ renderBootstrap3 BootstrapBasicForm
        $ modifySupplierForm sup
      case res of
        FormSuccess msup -> do
          runDB $ update sId
            [ SupplierIdent =. supConfIdent msup
            , SupplierAddress =. supConfAddr msup
            , SupplierTel =. supConfTel msup
            , SupplierEmail =. supConfEmail msup
            , SupplierCustomerId =. supConfCustomerId msup
            , SupplierAvatar =. supConfAvatar msup
            ]
          setMessageI MsgSupplierEdited
          redirect SupplierR
        _ -> do
          setMessageI MsgSupplierNotEdited
          redirect SupplierR
    Nothing -> do
      setMessageI MsgSupplierUnknown
      redirect SupplierR
postModifySupplierR sId = do
  mSup <- runDB $ get sId
  case mSup of
    Just sup -> do
      ((res, _), _) <- runFormPost
        $ renderBootstrap3 BootstrapBasicForm
        $ modifySupplierForm sup
      case res of
        FormSuccess msup -> do
          runDB $ update sId
            [ SupplierIdent =. supConfIdent msup
            , SupplierAddress =. supConfAddr msup
            , SupplierTel =. supConfTel msup
            , SupplierEmail =. supConfEmail msup
            , SupplierCustomerId =. supConfCustomerId msup
            , SupplierAvatar =. supConfAvatar msup
            ]
          setMessageI MsgSupplierEdited
          redirect SupplierR
        _ -> do
          setMessageI MsgSupplierNotEdited
          redirect SupplierR
    Nothing -> do
      setMessageI MsgSupplierUnknown
      redirect SupplierR