Пример #1
0
        public async Task <IActionResult> Index(SearchEmployeeQuery query)
        {
            _builder.Link(RelTypes.Nav, "Employees", SearchUri(query))
            .Link(Url.AppLink(RelTypes.Nav, "Client", "index", "client"))
            .Link(RelTypes.Breadcrumb, "Employees", SearchUri(query))
            .Link(RelTypes.Action, "+ new employee", AddUri())
            .Link(RelTypes.Self, "Employees", SearchUri(query))
            .Link(RelTypes.Search, "Search", SearchUri(new SearchEmployeeQuery(nameof(SearchEmployeeQuery.EmployeeNo))));

            var queryExecutionResult = await _employeeService.HandleAsync(query);

            if (queryExecutionResult.HasError == false)
            {
                if (queryExecutionResult.Result.PageNo > queryExecutionResult.Result.FirstPageNo)
                {
                    _builder.Link(RelTypes.First, "First", SearchUri(new SearchEmployeeQuery(query.EmployeeNo, queryExecutionResult.Result.FirstPageNo)))
                    .Link(RelTypes.Prev, "Previous", SearchUri(new SearchEmployeeQuery(query.EmployeeNo, queryExecutionResult.Result.PageNo - 1)));
                }

                if (queryExecutionResult.Result.PageNo < queryExecutionResult.Result.LastPageNo)
                {
                    _builder.Link(RelTypes.Next, "Next", SearchUri(new SearchEmployeeQuery(query.EmployeeNo, queryExecutionResult.Result.PageNo + 1)))
                    .Link(RelTypes.Last, "Last", SearchUri(new SearchEmployeeQuery(query.EmployeeNo, queryExecutionResult.Result.LastPageNo)));
                }

                foreach (var employee in queryExecutionResult.Result)
                {
                    _builder.Embedded(RelTypes.Row)
                    .Property("name", "Name", employee.FullName)
                    .Property(nameof(employee.EmployeeNo), "Employee No", employee.EmployeeNo)
                    .Property(nameof(employee.Created), "Created", employee.Created)
                    .Link(RelTypes.Self, employee.FullName, GeneralInfoUri(new UpdateEmployeeGeneralInfoQuery(employee.EmployeeId)))
                    .Link(Url.AppLink(RelTypes.Nav, "+ new client", nameof(ClientController.Add), nameof(ClientController), new CreateClientQuery(employee.EmployeeId)));
                }
            }

            var vm = _builder.Build()
                     .ToGridVm();

            return(View(vm));
        }
        public async Task <IActionResult> Index(SearchClientQuery query)
        {
            _builder.Link(Url.AppLink(RelTypes.Breadcrumb, "Clients", nameof(Index), nameof(ClientController)))
            .Link(Url.AppLink(RelTypes.Nav, "Employees", nameof(EmployeeController.Index), nameof(EmployeeController)))
            .Link(Url.AppLink(RelTypes.Nav, "Clients", nameof(ClientController.Index), nameof(ClientController)))
            .Link(Url.AppLink(RelTypes.Action, "+ new client", nameof(ClientController.Add), nameof(ClientController)))
            .Link(Url.AppLink(RelTypes.Self, "Clients", nameof(Index), nameof(ClientController)));

            var commandExecutionResult = await _clientService.HandleAsync(query);

            if (commandExecutionResult.HasError == false)
            {
                if (commandExecutionResult.Result.PageNo > commandExecutionResult.Result.FirstPageNo)
                {
                    _builder.Link(Url.AppLink(RelTypes.First, "First", nameof(Index), nameof(ClientController), new SearchClientQuery(query.ClientNo, commandExecutionResult.Result.FirstPageNo)))
                    .Link(Url.AppLink(RelTypes.Prev, "Previous", nameof(Index), nameof(ClientController), new SearchClientQuery(query.ClientNo, commandExecutionResult.Result.PageNo - 1)));
                }

                if (commandExecutionResult.Result.PageNo < commandExecutionResult.Result.LastPageNo)
                {
                    _builder.Link(Url.AppLink(RelTypes.Next, "Next", nameof(Index), nameof(ClientController), new SearchClientQuery(query.ClientNo, commandExecutionResult.Result.PageNo + 1)))
                    .Link(Url.AppLink(RelTypes.Last, "Last", nameof(Index), nameof(ClientController), new SearchClientQuery(query.ClientNo, commandExecutionResult.Result.LastPageNo)));
                }

                foreach (var client in commandExecutionResult.Result)
                {
                    _builder.Embedded(RelTypes.Row)
                    .Property(nameof(client.Name), "Name", client.Name)
                    .Property(nameof(client.ClientNo), "Client No", client.ClientNo)
                    .Property(nameof(client.Created), "Created", client.Created)
                    .Link(Url.AppLink(RelTypes.Self, "Name", nameof(Edit), nameof(ClientController), new UpdateClientQuery(client.ClientId)));
                }
            }

            var vm = _builder.Build()
                     .ToGridVm();

            return(View("GridView", vm));
        }
Пример #3
0
        private void Build()
        {
            Busy = true;
            try {
                using (IModelContext context = _contextFactory.Create(ConnectionString, false)) {
                    using (ICodeWriter codeWriter = _codeWriterFactory.Create(CodeFile)) {
                        using (IResourceBuilder resourceBuilder =
                                   _resourceBuilderFactory.CreateResXBuilder(ResFile)) {
                            Build(context, codeWriter, resourceBuilder);
                            resourceBuilder.Build();
                        }
                    }
                }

                SaveFolder();
                _actionHelper.Dispatch(() => { View.DialogResult = true; });
            } catch (Exception exception) {
                _dialogHelper.Exception(exception, View);
            } finally {
                Busy = false;
            }
        }
Пример #4
0
 public IActionResult Get()
 {
     return(Ok(
                _resourceBuilder.Build(new StatusResource())
                ));
 }
Пример #5
0
 public IActionResult GetResetPasswordResourceTemplate()
 {
     return(Ok(_resourceBuilder.Build(new GoogleAuthenticationServiceTemplate())));
 }
        public async Task <IActionResult> Get()
        {
            IdentityAdto identityAdto = await _identityApplicationService.GetAsync(new GetIdentityAdto
            {
                Id = _currentIdentityProvider.Id
            });

            switch (identityAdto)
            {
            case PasswordIdentityAdto passwordIdentityAdto:
                return(Ok(_resourceBuilder.Build(new PasswordIdentityResource
                {
                    Id = passwordIdentityAdto.Id
                })));

            case IdentityAdto defaultIdentityAdto:
                return(Ok(_resourceBuilder.Build(new IdentityResource
                {
                    Id = defaultIdentityAdto.Id
                })));

            default:
                throw new ArgumentOutOfRangeException(nameof(identityAdto));
            }
        }
 public IActionResult GetPasswordResourceTemplate()
 {
     return(Ok(_resourceBuilder.Build(new PasswordTemplate())));
 }
Пример #8
0
 public IActionResult Get(Guid userId)
 {
     return(new ObjectResult(
                _resourceBuilder.Build(new CreateLogsheetResource())
                ));
 }