public Task <IActionResult> HandleDeleteConfirmedAsync(
     Action <TEntity> setPageEntity,
     Func <TUserContext, bool> authorize,
     string formEntityPrefix,
     Func <TEntity> constructor,
     Dictionary <string, Func <TEntity, Action <StringValues> > > hiddenFormFields
     ) =>
 HandlePageSaveAsync(setPageEntity, pageRoutineFeature,
                     (repository, closure) => steps =>
                     steps(
                         () => authorize?.Invoke(closure.UserContext) ?? true,
                         request => MvcHandler.Bind(request, formEntityPrefix, constructor,
                                                    // TODO: convert to Empty instance
                                                    new Dictionary <string, Func <TEntity, Func <StringValues, IVerboseResult <List <string> > > > >(),
                                                    hiddenFormFields),
                         (entity, batch) => batch.Remove(entity)
                         )
                     );
 public Task <IActionResult> HandleCreateConfirmedAsync(
     Action <TEntity> setPageEntity,
     Func <TUserContext, bool> authorize,
     string formEntityPrefix,
     Func <TEntity> constructor,
     Dictionary <string, Func <TEntity, Func <StringValues, IVerboseResult <List <string> > > > > formFields,
     Dictionary <string, Func <TEntity, Action <StringValues> > > hiddenFormFields,
     Func <Action <string, object>, HttpRequest, IRepository <TEntity>, TEntity, IComplexBinderResult <ValueTuple <Action <IBatch <TEntity> >, Action> > > parseRelated
     ) =>
 HandlePageSaveAsync(setPageEntity, pageRoutineFeature,
                     (repository, closure) => steps =>
                     steps(
                         () => authorize?.Invoke(closure.UserContext) ?? true,
                         request => MvcHandler.Bind(request, formEntityPrefix, constructor, formFields, hiddenFormFields),
                         (request, entity, addViewData) => parseRelated(addViewData, request, repository, entity),
                         (entity, batch) => batch.Add(entity)
                         )
                     );
Exemple #3
0
 public IActionResult HandlePageSave <TEntity>(
     Action <TEntity> setPageEntity,
     PageRoutineFeature pageRoutineFeature,
     Func <
         IRepository <TEntity>,
         RoutineClosure <TUserContext>,
         Func <
             Func <
                 Func <bool>,
                 Func <HttpRequest, IComplexBinderResult <TEntity> >,
                 Func <HttpRequest, TEntity, Action <string, object>, IComplexBinderResult <ValueTuple <Action <IBatch <TEntity> >, Action> > >,
                 Action <TEntity, IBatch <TEntity> >,
                 IActionResult>,
             IActionResult
             >
         > action
     ) where TEntity : class =>
 PageRoutineHandler.Handle((container, closure) =>
                           container.HandleStorage <IActionResult, TEntity>((repository, storage, state) =>
                                                                            MvcHandler.MakeActionResultOnSave(
                                                                                repository,
                                                                                storage,
                                                                                state,
                                                                                () => PageModel.Unauthorized(),
                                                                                PageModel.HttpContext.Request,
                                                                                (n, v) => PageModel.ViewData[n] = v,
                                                                                (n, v) => PageModel.ModelState.AddModelError(n, v),
                                                                                //Redirect(BackwardString);
                                                                                () => new RedirectResult(pageRoutineFeature.Referrer),
                                                                                (m) => {
     return(PageModel.BadRequest());
 },
                                                                                o => {
     setPageEntity(o);
     return(PageModel.Page());
 },
                                                                                action
                                                                                )
                                                                            )
                           );
Exemple #4
0
 public IActionResult HandlePageCreate <TEntity>(
     Action <TEntity> setPageEntity,
     Func <
         IRepository <TEntity>,
         RoutineClosure <TUserContext>,
         Func <
             Func <
                 Func <bool>,
                 Func <TEntity>,
                 Action <TEntity, Action <string, object> >,
                 IActionResult>,
             IActionResult>
         > action
     ) where TEntity : class =>
 PageRoutineHandler.Handle((container, closure) =>
                           container.HandleRepository <IActionResult, TEntity>(repository =>
                                                                               MvcHandler.MakeActionResultOnCreate(
                                                                                   repository,
                                                                                   (n, v) => PageModel.ViewData[n] = v,
                                                                                   () => PageModel.Unauthorized(),
                                                                                   PageModel.HttpContext.Request,
                                                                                   o => {
     setPageEntity(o);
     return(PageModel.Page());
 },
                                                                                   (r) => action(r, closure)
                                                                                   )
                                                                               )
                           );
Exemple #5
0
        public Task <IActionResult> HandlePageSaveAsync <TEntity>(
            Action <TEntity> setPageEntity,
            PageRoutineFeature pageRoutineFeature,
            Func <
                IRepository <TEntity>,
                RoutineClosure <TUserContext>,
                Func <
                    Func <
                        Func <bool>,
                        Func <HttpRequest, IComplexBinderResult <TEntity> >,
                        Action <TEntity, IBatch <TEntity> >,
                        IActionResult>,
                    IActionResult
                    >
                > action
            ) where TEntity : class =>
        PageRoutineHandler.HandleAsync(async(container, closure) =>
                                       await container.HandleStorageAsync <IActionResult, TEntity>((repository, storage, state) =>
                                                                                                   Task.Run(
                                                                                                       () => MvcHandler.MakeActionResultOnSave(
                                                                                                           repository,
                                                                                                           storage,
                                                                                                           state,
                                                                                                           () => PageModel.Unauthorized(),
                                                                                                           PageModel.HttpContext.Request,
                                                                                                           (n, v) => PageModel.ViewData[n] = v,
                                                                                                           (n, v) => PageModel.ModelState.AddModelError(n, v),

                                                                                                           () => new RedirectResult(pageRoutineFeature.Referrer),
                                                                                                           (m) => {
            return(PageModel.BadRequest());
        },
                                                                                                           o => {
            setPageEntity(o);
            return(PageModel.Page());
        },
                                                                                                           action
                                                                                                           )
                                                                                                       )
                                                                                                   )
                                       );
Exemple #6
0
 public IActionResult HandlePageRequest <TKey, TEntity>(
     Action <TEntity> setPageEntity,
     Func <
         IRepository <TEntity>,
         RoutineClosure <TUserContext>,
         Func <
             Func <
                 Func <bool>,
                 Func <string, ValuableResult <TKey> >,
                 Func <TKey, TEntity>,
                 IActionResult>,
             IActionResult>
         > action
     ) where TEntity : class =>
 PageRoutineHandler.Handle((container, closure) =>
                           container.HandleRepository <IActionResult, TEntity>(repository =>
                                                                               MvcHandler.MakeActionResultOnRequest(
                                                                                   repository,
                                                                                   () => PageModel.Unauthorized(),
                                                                                   PageModel.HttpContext.Request,
                                                                                   o => {
     setPageEntity(o);
     return(PageModel.Page());
 },
                                                                                   (m) => {
     return(PageModel.BadRequest());
 },
                                                                                   PageModel.NotFound,
                                                                                   (r) => action(r, closure)
                                                                                   )
                                                                               )
                           );
Exemple #7
0
 public Task <IActionResult> HandlePageCreateAsync <TEntity>(
     Action <object> setPageEntity,
     Func <
         IRepository <TEntity>,
         RoutineClosure <TUserContext>,
         Func <
             Func <
                 Func <bool>,
                 Func <TEntity>,
                 //Action<TEntity, Action<string, object>>,
                 IActionResult>,
             IActionResult>
         > action
     ) where TEntity : class =>
 PageRoutineHandler.HandleAsync(async(container, closure) =>
                                await container.HandleRepositoryAsync <IActionResult, TEntity>(repository =>
                                                                                               Task.Run(
                                                                                                   () => MvcHandler.MakeActionResultOnCreate(
                                                                                                       repository,
                                                                                                       () => PageModel.Unauthorized(),
                                                                                                       PageModel.HttpContext.Request,
                                                                                                       o => {
     setPageEntity(o);
     return(PageModel.Page());
 },
                                                                                                       (r) => action(r, closure)
                                                                                                       ))
                                                                                               )
                                );
Exemple #8
0
        public Task <IActionResult> HandlePageRequestAsync <TKey, TEntity>(
            Action <TEntity> setPageEntity,
            Func <
                IRepository <TEntity>,
                RoutineClosure <TUserContext>,
                Func <
                    Func <
                        Func <bool>,
                        Func <string, ValuableResult <TKey> >,
                        Func <TKey, TEntity>,
                        Action <TEntity, Action <string, object> >,
                        IActionResult>,
                    IActionResult>
                > action
            ) where TEntity : class =>

        PageRoutineHandler.HandleAsync(async(container, closure) =>
                                       await container.HandleRepositoryAsync <IActionResult, TEntity>(repository =>
                                                                                                      Task.Run(() =>
                                                                                                               MvcHandler.MakeActionResultOnRequest(
                                                                                                                   repository,

                                                                                                                   (n, v) => PageModel.ViewData[n] = v,
                                                                                                                   () => PageModel.Unauthorized(),
                                                                                                                   PageModel.HttpContext.Request,
                                                                                                                   o => {
            setPageEntity(o);
            return(PageModel.Page());
        },
                                                                                                                   (m) => {
            return(PageModel.BadRequest());
        },
                                                                                                                   PageModel.NotFound,
                                                                                                                   (r) => action(r, closure)
                                                                                                                   )
                                                                                                               )
                                                                                                      )
                                       );