Ejemplo n.º 1
0
        public async Task <IActionResult> Put([FromBody] UpdateClientModel updateClient)
        {
            await _clientDataAccess.UpdateClient(updateClient.Id,
                                                 updateClient.ClientName,
                                                 updateClient.Address,
                                                 updateClient.City,
                                                 updateClient.ZIP,
                                                 updateClient.Country,
                                                 updateClient.Phone);

            return(Ok());
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Edit(int id)
        {
            var response = await GetToApi(string.Concat("clients/", id));

            var client = JsonConvert.DeserializeObject <ClientDto>(await response.Content.ReadAsStringAsync());

            var model = new UpdateClientModel()
            {
                Id           = client.Id,
                Name         = client.Name,
                ClientSecret = client.ClientSecret,
                Description  = client.Description,
                PublicId     = client.PublicId,
                ReturnUrls   = client.ReturnUrls.Select(ru => ru.Value).ToList(),
                ClientType   = client.ClientType,
                Scopes       = new Dictionary <string, IList <ScopeClientModel> >()
            };

            // get all scopes
            var responseScopes = await GetToApi("scopes");

            if (!await model.ValidateAsync(response))
            {
                return(View(responseScopes));
            }

            IList <int> clientScopes = client.Scopes.Select(s => s.Id).ToList();

            var scopes = JsonConvert.DeserializeObject <SearchResult <ScopeDto> >(await responseScopes.Content.ReadAsStringAsync());

            if (scopes != null)
            {
                foreach (var s in scopes.Datas)
                {
                    if (!model.Scopes.ContainsKey(s.RessourceServerName))
                    {
                        model.Scopes.Add(s.RessourceServerName, new List <ScopeClientModel>());
                    }

                    model.Scopes[s.RessourceServerName].Add(new ScopeClientModel()
                    {
                        Id          = s.Id,
                        NiceWording = s.NiceWording,
                        Selected    = clientScopes.Contains(s.Id),
                        Wording     = s.Wording
                    });
                }
            }

            return(View(model));
        }
        public MainWindowViewModel()
        {
            //CheckConfiguration();
            _monitoringModel = new ClientMonitoringModel();
            Model = _monitoringModel;
            _monitoringTree = new MonitoringTreeViewModel(_monitoringModel);
            _changeCertificateModel = new ChangeClientCertificateViewModel(_monitoringModel);
            _updateModel = new UpdateClientModel(_monitoringModel);
            _updateModel.UpdateClient += UpdateModel_UpdateClient;
            _updateClientViewModel = new UpdateClientViewModel(_updateModel);

            IDialogModelFactory factory = new DialogModelFactory(_monitoringModel.SensorHistoryConnector);
            DialogSensorExpandingService expandingService = new DialogSensorExpandingService(factory);
            //expandingService.RegisterDialog(SensorTypes.BoolSensor, typeof(DefaultValuesListSensorView),
            //    typeof(DefaultValuesListSensorView));
            expandingService.RegisterDialog(SensorTypes.BoolSensor, typeof(NumericSensorView),
                typeof(ClientBoolTimeValueModel));
            //expandingService.RegisterDialog(SensorTypes.IntSensor, typeof(DefaultValuesListSensorView),
            //    typeof(ClientDefaultValuesListSensorModel));
            expandingService.RegisterDialog(SensorTypes.IntSensor, typeof(NumericSensorView),
                typeof(ClientIntTimeValueModel));
            //expandingService.RegisterDialog(SensorTypes.DoubleSensor, typeof(DefaultValuesListSensorView),
            //    typeof(ClientDefaultValuesListSensorModel));
            expandingService.RegisterDialog(SensorTypes.DoubleSensor, typeof(NumericSensorView),
                typeof(ClientDoubleTimeValueModel));
            expandingService.RegisterDialog(SensorTypes.StringSensor, typeof(DefaultValuesListSensorView),
                typeof(ClientDefaultValuesListSensorModel));
            //expandingService.RegisterDialog(SensorTypes.BarIntSensor, typeof(DefaultValuesListSensorView),
            //    typeof(ClientDefaultValuesListSensorModel));
            expandingService.RegisterDialog(SensorTypes.BarIntSensor, typeof(BarSensorView),
                typeof(ClientIntBarSensorModel));
            //expandingService.RegisterDialog(SensorTypes.BarDoubleSensor, typeof(DefaultValuesListSensorView),
            //    typeof(ClientDefaultValuesListSensorModel));
            expandingService.RegisterDialog(SensorTypes.BarDoubleSensor, typeof(BarSensorView),
                typeof(ClientDoubleBarSensorModel));
            expandingService.RegisterDialog(SensorTypes.FileSensor, typeof(object),
                typeof(ClientFileSensorModel));

            _monitoringTree.SensorExpandingService = expandingService;

            _monitoringModel.ShowProductsEvent += monitoringModel_ShowProductsEvent;
            _monitoringModel.ShowSettingsWindowEvent += monitoringModel_ShowSettingsWindowEvent;
            _monitoringModel.ShowGenerateCertificateWindowEvent += monitoringModel_ShowGenerateCertificateWindowEvent;
            //_monitoringModel.DefaultCertificateReplacedEvent += monitoringModel_DefaultCertificateReplacedEvent;
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> Edit(UpdateClientModel model)
        {
            var response = await PutToApi("clients", new UpdateClientDto()
            {
                ClientType   = model.ClientType,
                ReturnUrls   = model.ReturnUrls.Where(ru => !String.IsNullOrWhiteSpace(ru)).ToList(),
                Description  = model.Description,
                Name         = model.Name,
                Id           = model.Id,
                ClientSecret = model.ClientSecret,
                PublicId     = model.PublicId,
                ScopesIds    = model.Scopes.SelectMany(s => s.Value)
                               .Where(sv => sv.Selected)
                               .Select(sv => sv.Id).ToList()
            });

            return(!await model.ValidateAsync(response) ? View(model) : (IActionResult)RedirectToAction("List"));
        }
Ejemplo n.º 5
0
        public async Task <ActionResult <Client> > ClientAsync([FromBody] UpdateClientModel updateClientModel)
        {
            try
            {
                var client = await _mediator.Send(new GetClientByIdQuery
                {
                    Id = updateClientModel.Id
                });

                if (client == null)
                {
                    return(BadRequest($"No client found with the id {updateClientModel.Id}"));
                }

                return(await _mediator.Send(new UpdateClientCommand
                {
                    Client = _mapper.Map(updateClientModel, client)
                }));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Ejemplo n.º 6
0
        public async Task <ClientsItem> UpsertAsync(UpdateClientModel item)
        {
            var client = _mapper.Map <ClientsItem>(item);

            return(await _clientsDataService.UpsertAsync(client));
        }
Ejemplo n.º 7
0
        public virtual async Task <ActionResult <int> > Update(UpdateClientModel item)
        {
            var updateItemId = await _clientService.UpsertAsync(item);

            return(Ok(updateItemId));
        }