public void Init(string id)
        {
            if (string.IsNullOrWhiteSpace(id))
            {
                return;
            }

            Client = _dashboardService.LoadClient(new Guid(id));
            Module = _dashboardService.LoadModule();
            DefaultEncounterType = _lookupService.GetDefaultEncounterType();

            if (null != Client)
            {
                var clientJson = JsonConvert.SerializeObject(Client);
                _settings.AddOrUpdateValue("client", clientJson);

                var clientDto     = ClientDTO.Create(Client);
                var clientDtoJson = JsonConvert.SerializeObject(clientDto);
                _settings.AddOrUpdateValue("client.dto", clientDtoJson);
            }

            if (null != Module)
            {
                var moduleJson = JsonConvert.SerializeObject(Module);
                _settings.AddOrUpdateValue("module", moduleJson);
            }

            if (null != DefaultEncounterType)
            {
                var encounterTypeJson = JsonConvert.SerializeObject(DefaultEncounterType);
                _settings.AddOrUpdateValue("encountertype", encounterTypeJson);
            }
        }
Exemple #2
0
        public void Init(string id, string callerId, string mode)
        {
            if (string.IsNullOrWhiteSpace(id))
            {
                return;
            }

            if (!string.IsNullOrWhiteSpace(callerId))
            {
                _settings.AddOrUpdateValue("callerId", callerId);
                _settings.AddOrUpdateValue("activetabId", 1);
                IndexClient = new IndexClientDTO(new Guid(callerId));
                _settings.AddOrUpdateValue("myIndexId", JsonConvert.SerializeObject(IndexClient));
            }
            else
            {
                if (_settings.Contains("callerId"))
                {
                    _settings.DeleteValue("callerId");
                }
                if (_settings.Contains("activetabId"))
                {
                    _settings.DeleteValue("activetabId");
                }
            }

            if (!string.IsNullOrWhiteSpace(mode))
            {
                _settings.AddOrUpdateValue("emod", mode);
            }
            else
            {
                if (_settings.Contains("emod"))
                {
                    _settings.DeleteValue("emod");
                }
            }

            Client  = _dashboardService.LoadClient(new Guid(id));
            Modules = _dashboardService.LoadModules();

            if (null != Client)
            {
                var clientJson = JsonConvert.SerializeObject(Client);
                _settings.AddOrUpdateValue("client", clientJson);

                var clientDto     = ClientDTO.Create(Client);
                var clientDtoJson = JsonConvert.SerializeObject(clientDto);
                _settings.AddOrUpdateValue("client.dto", clientDtoJson);
            }

            if (null != Modules)
            {
                var modulesJson = JsonConvert.SerializeObject(Modules);
                _settings.AddOrUpdateValue("modules", modulesJson);
            }
        }
        public override void ViewAppeared()
        {
            //  Reload

            var clientJson  = _settings.GetValue("client", "");
            var modulesJson = _settings.GetValue("modules", "");
            var indexJson   = _settings.GetValue("myIndexId", "");

            if (null == Client)
            {
                if (!string.IsNullOrWhiteSpace(clientJson))
                {
                    var client = JsonConvert.DeserializeObject <Client>(clientJson);
                    Client = JsonConvert.DeserializeObject <Client>(clientJson);
                    var clientDto     = ClientDTO.Create(Client);
                    var clientDtoJson = JsonConvert.SerializeObject(clientDto);
                    _settings.AddOrUpdateValue("client.dto", clientDtoJson);
                }
            }

            if (null == Modules)
            {
                if (!string.IsNullOrWhiteSpace(modulesJson))
                {
                    Modules = JsonConvert.DeserializeObject <List <Module> >(modulesJson);
                }
            }

            if (null != Client)
            {
                PartnerViewModel.Client = EncounterViewModel.Client = Client;
                SummaryViewModel.Client = Client;
            }

            if (null != IndexClient)
            {
                if (!string.IsNullOrWhiteSpace(indexJson))
                {
                    IndexClient = JsonConvert.DeserializeObject <IndexClientDTO>(indexJson);
                }
            }
        }
        public ObjectResponse <List <ClientDTO> > GetClients(string searchText)
        {
            try
            {
                var response = _unitOfWork.ClientsRepository.GetAll();
                if (!String.IsNullOrWhiteSpace(searchText))
                {
                    var searchKey = searchText.ToLower();
                    response = response.Where(x => searchKey.Contains(x.client_id.ToString().ToLower()) ||
                                              searchKey.Contains(x.first_name.ToLower()) || searchKey.Contains(x.last_name.ToLower()));
                }

                return(new ObjectResponse <List <ClientDTO> > {
                    Success = true, Data = response.ToList()?.Select(x => ClientDTO.Create(x))?.ToList()
                });
            }
            catch (Exception ex)
            {
                return(new ObjectResponse <List <ClientDTO> > {
                    Success = false, Error = ex.GetBaseException().Message, Info = DB_GET_ERROR
                });
            }
        }