public async Task <ResultViewModel> Update(
            [FromRoute] string client_id,
            [FromBody] UpdateClientViewModel clientModel)
        {
            bool clientIdIsValid = Guid.TryParse(client_id, out Guid output);

            if (!clientIdIsValid)
            {
                return new ResultViewModel()
                       {
                           Success = false,
                           Message = "ID inválido."
                       }
            }
            ;

            var client = await _clientRepository.Find(client_id);

            if (client == null)
            {
                return new ResultViewModel()
                       {
                           Success = false,
                           Message = "Cliente não encontrado."
                       }
            }
            ;

            if (clientModel.OldPassword != null)
            {
                client.SetPassword(clientModel.OldPassword, clientModel.NewPassword);
            }

            if (clientModel.Telephone != null)
            {
                client.SetTelephone(clientModel.Telephone);
            }


            if (client.Invalid)
            {
                return new ResultViewModel()
                       {
                           Success = false,
                           Message = "Dados inválidos.",
                           Data    = client.Notifications
                       }
            }
            ;

            await _clientRepository.Update(client);

            return(new ResultViewModel()
            {
                Success = true,
                Message = null,
                Data = new ListClientViewModel(client)
            });
        }
        public ClientReferencePage(Client client)
        {
            InitializeComponent();
            var updateClientViewModel = new UpdateClientViewModel(Navigation);

            updateClientViewModel.Client = client;
            BindingContext = updateClientViewModel;
        }
Exemple #3
0
        private void ValidateClient(UpdateClientViewModel client, Guid?clientId = null)
        {
            ValidationUtils.ValidateViewModel(client);

            if (_clientRepository.ClientWithNameExists(client.Name, clientId))
            {
                throw new EntityValidationException("A client with this name already exists.");
            }
        }
        public UpdateClientPage(Client client)
        {
            InitializeComponent();

            var updateClientViewModel = new UpdateClientViewModel(Navigation);

            updateClientViewModel.Client = client;
            BindingContext = updateClientViewModel;

            NavigationPage.SetHasNavigationBar(this, false);  // Hide nav bar
        }
Exemple #5
0
        async void Delete()
        {
            var response = await dialogService.ShowConfirm(
                "Confirm",
                "Are you sure to delete this Reference ?");

            if (!response)
            {
                return;
            }

            await UpdateClientViewModel.GetInstance().DeleteReference(this);
        }
        public ActionResult Update(ClientFormPartialViewModel form)
        {
            if (!ModelState.IsValid)
            {
                _clientsViewModel.AccordionItemsPartialViewModel.InvalidClientId = form.Client.Id;
                return(Index());
            }
            IClient client = new UpdateClientViewModel(form.Client.Id, form.Client.Name, form.Client.Address, form.Client.City, form.Client.ZipCode, form.Client.CountryId);

            _clientService.UpdateClientById(client);

            return(RedirectToAction("Index"));
        }
        public IActionResult Update(int id)
        {
            Client updateClient      = _dataservice.getClient(id);
            UpdateClientViewModel vm = new UpdateClientViewModel
            {
                Name    = updateClient.Name,
                Dob     = updateClient.Dob.ToString("dd,MM,yyyy"),
                Contact = updateClient.Contact,
                Mobile  = updateClient.Mobile,
                Email   = updateClient.Email
            };

            return(View(vm));
        }
        public IActionResult Update(int id, UpdateClientViewModel vm)
        {
            Client client = _dataservice.getClient(id);

            if (ModelState.IsValid)
            {
                client.Name    = vm.Name;
                client.Dob     = DateTime.Parse(vm.Dob);
                client.Contact = vm.Contact;
                client.Mobile  = vm.Mobile;
                client.Email   = vm.Email;
                _dataservice.updateClient();
                return(RedirectToAction("Details", new { id = client.ClientId }));
            }
            return(View(vm));
        }
        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;
        }
Exemple #10
0
        public ClientViewModel Update(Guid id, UpdateClientViewModel vm)
        {
            ValidateClient(vm, id);

            var client = PerformActionOnClient(id, c =>
            {
                if (!string.Equals(c.Name, vm.Name))
                {
                    c.Rename(vm.Name);
                }

                if (!string.Equals(c.Description, vm.Description))
                {
                    c.Redescribe(vm.Description);
                }
            });

            return(client.ToViewModel());
        }
Exemple #11
0
        public ClientCreatedViewModel Create(UpdateClientViewModel vm)
        {
            ValidateClient(vm);

            var secret = Guid.NewGuid().ToString();

            // Create the client domain object and save it's events
            var client = new Client(vm.Name, secret, vm.Description);

            //Save the client
            SaveClient(client);

            return(new ClientCreatedViewModel()
            {
                Id = client.Id,
                Name = client.Name,
                Description = client.Description,
                Secret = secret,
                Active = client.Active
            });
        }
Exemple #12
0
        public ActionResult UpdateClient(SelectClientViewModel vm)
        {
            int?SiteID = Session["SiteID"] as int?;


            if (SiteID.HasValue)
            {
                vm.SiteID = SiteID.Value;
            }

            vm.SiteName = Session["SiteName"] as string;

            // Update client attributes based on user input
            string sql = String.Format(
                "UPDATE client SET DescriptiveID = '{0}', " +
                "FirstName = '{1}', " +
                "MiddleName = '{2}', " +
                "LastName = '{3}', " +
                "PhoneNumber = '{4}' " +
                "WHERE ClientID = {5}; ",
                vm.DescriptiveID.ToString(), vm.FirstName.ToString(), vm.MiddleName, vm.LastName.ToString(),
                vm.PhoneNumber.ToString(), vm.ClientID);

            SqlHelper.ExecuteNonQuery(sql);

            // Query is built up based on what attributes were changed. This becomes a log entry within the log table for the client.
            string  mod_string     = String.Format("Profile updated/edited: ");
            Boolean updateHappened = false;

            if (vm.oldDescriptiveID != vm.DescriptiveID)
            {
                updateHappened = true;
                mod_string    += String.Format("DescriptiveID changed from {0} to {1}; ", vm.oldDescriptiveID, vm.DescriptiveID);
            }
            if (vm.oldFirstName != vm.FirstName)
            {
                updateHappened = true;
                mod_string    += String.Format("First name changed from {0} to {1}; ", vm.oldFirstName, vm.FirstName);
            }
            if (vm.oldMiddleName != vm.MiddleName)
            {
                updateHappened = true;
                mod_string    += String.Format("Middle name changed from {0} to {1}; ", vm.oldMiddleName, vm.MiddleName);
            }
            if (vm.oldLastName != vm.LastName)
            {
                updateHappened = true;
                mod_string    += String.Format("Last name changed from {0} to {1}; ", vm.oldLastName, vm.LastName);
            }
            if (vm.oldPhoneNumber != vm.PhoneNumber)
            {
                updateHappened = true;
                mod_string    += String.Format("Phone Number changed from {0} to {1}; ", vm.oldPhoneNumber, vm.PhoneNumber);
            }

            // Log auto generated message for changing of values
            if (updateHappened)
            {
                // Insert logentry for changing of client attributes
                sql = String.Format(
                    "INSERT INTO clientlogentry (ClientID, SiteName, Description) " +
                    "VALUES ({0}, '{1}', '{2}'); ",
                    vm.ClientID, vm.SiteName, mod_string
                    );

                SqlHelper.ExecuteNonQuery(sql);
            }

            //Add manual log entry if user provided one
            if (vm.LogEntry != null)
            {
                sql = String.Format(
                    "INSERT INTO clientlogentry (ClientID, SiteName, Description) " +
                    "VALUES ({0}, '{1}', '{2}'); ",
                    vm.ClientID, vm.SiteName, vm.LogEntry
                    );

                SqlHelper.ExecuteNonQuery(sql);
            }

            UpdateClientViewModel om = new UpdateClientViewModel();



            if (vm.selectedBunk != null)
            {
                // If Check-in radio button is selected, decrement the selected bunk number from bunklist
                sql = String.Format(
                    "UPDATE shelter SET {0} = {0} - 1 " +
                    "WHERE SiteID = {1}; ",
                    vm.selectedBunk, vm.SiteID);

                SqlHelper.ExecuteNonQuery(sql);

                // Add logging for check into bunk based on what bunk was selected
                string checkInLogEntry = "Checked into ";
                if (vm.selectedBunk == "MaleBunksAvailable")
                {
                    checkInLogEntry += "male bunk. ";
                }
                else if (vm.selectedBunk == "FemaleBunksAvailable")
                {
                    checkInLogEntry += "female bunk. ";
                }
                else
                {
                    checkInLogEntry += "mixed bunk. ";
                }

                // Add an additional note is provided for bunk check-in
                if (vm.ShelterLogEntry != null)
                {
                    checkInLogEntry += String.Format("Additional Note: {0}", vm.ShelterLogEntry);
                }

                // INsert og entry for bunk check-in
                sql = String.Format(
                    "INSERT INTO clientlogentry (ClientID, ServiceName, SiteName, Description) " +
                    "VALUES ({0}, '{1}', '{2}', '{3}'); ",
                    vm.ClientID, vm.ShelterServiceName, vm.SiteName, checkInLogEntry
                    );

                SqlHelper.ExecuteNonQuery(sql);
            }

            // Add log entry if check in for food pantry occured
            if (vm.FoodPantryCheckIn)
            {
                string food_itemlog = "Provide Food Item(s). ";
                if (vm.FoodPantryLogEntry != null)
                {
                    food_itemlog += String.Format("Additional Note: {0}", vm.FoodPantryLogEntry);
                }
                sql = String.Format(
                    "INSERT INTO clientlogentry (ClientID, ServiceName, SiteName, Description) " +
                    "VALUES ({0}, '{1}', '{2}', '{3}'); ",
                    vm.ClientID, vm.FoodPantryServiceName, vm.SiteName, food_itemlog
                    );

                SqlHelper.ExecuteNonQuery(sql);
            }

            // Add log entry if check in for soup kitchen occured
            if (vm.SoupKitchenCheckIn)
            {
                string soupkitchenlog = "Provide a meal. ";
                if (vm.SoupKitchenLogEntry != null)
                {
                    soupkitchenlog += String.Format("Additional Note: {0}", vm.SoupKitchenLogEntry);
                }
                sql = String.Format(
                    "INSERT INTO clientlogentry (ClientID, ServiceName, SiteName, Description) " +
                    "VALUES ({0}, '{1}', '{2}', '{3}'); ",
                    vm.ClientID, vm.SoupKitchenServiceName, vm.SiteName, soupkitchenlog
                    );

                SqlHelper.ExecuteNonQuery(sql);
            }



            // Get log list with new entry(or entries) to display
            sql = String.Format(
                "SELECT DateTimeStamp, ServiceName, SiteName, Description " +
                "FROM clientlogentry WHERE ClientID = {0} ", vm.ClientID);

            List <object[]> result = SqlHelper.ExecuteMultiSelect(sql, 4);

            if (result != null)
            {
                om.Logs = GetLogListFromQueryResponse(result);
            }
            om.StatusMessage = "Succesfully updated!";

            return(View(om));
        }
Exemple #13
0
 public async Task UpdateAsync(UpdateClientViewModel model)
 {
     var command = _mapper.Map <UpdateClientCommand>(model);
     await _bus.SendCommand(command);
 }
        public async Task <ActionResult <JsonResponse <bool> > > Put([FromBody] UpdateClientViewModel model)
        {
            await _clientService.UpdateAsync(model);

            return(JsonResponse(true));
        }
 public IActionResult Update(Guid id, [FromBody] UpdateClientViewModel client)
 {
     return(Ok(_clientService.Update(id, client)));
 }
 public IActionResult Create([FromBody] UpdateClientViewModel client)
 {
     return(Ok(_clientService.Create(client)));
 }