예제 #1
0
        private void UpdateProductsListview()
        {
            IsBusy = true;
            var query = DataStore.GetDataStoredJson("Products").ToList();

            if (query.Count > 0)
            {
                var _products = JsonConvert.DeserializeObject <List <Products_Model> >(query[0].json);
                Products.Clear();
                Filtred_List.Clear();
                foreach (var product in _products)
                {
                    if (Products_Presented_Ids != null && Products_Presented_Ids.Count > 0)
                    {
                        if (!Products_Presented_Ids.Contains(product._id))
                        {
                            Products.Add(product);
                            Filtred_List.Add(product);
                        }
                    }
                    else
                    {
                        Products.Add(product);
                        Filtred_List.Add(product);
                    }
                }
                SearchBarText = string.Empty;
            }
            IsBusy = false;
        }
예제 #2
0
        public Visite_ViewModel(string source, INavigation navigation, IDataStore dataStore, Client2 contact, bool isfreemission, string global_id, string mission_id, List <Client2> focuscontacts = null)
        {
            Navigation    = navigation;
            DataStore     = dataStore;
            Contact       = contact;
            IsFreeMission = isfreemission;
            Global_Id     = global_id;
            Mission_Id    = mission_id;
            Source        = source;
            if (Source == "Focus")
            {
                VisiteType    = "Rapport Focus.";
                Focus         = true;
                FocusContacts = focuscontacts;
                Contact       = FocusContacts.First();
            }
            else
            {
                VisiteType = "Ajouter Visite.";
            }
            Responce      = new Responce_Model();
            Responce_Free = new Responce_free_Model();
            Tmp_Presented_Products_Doctor     = new ObservableCollection <tmp_presented_products_doctor>();
            Tmp_Pretented_Products_Pharmacies = new ObservableCollection <tmp_pretented_products_pharmacy>();
            tmp_Questionnaires = new List <tmp_questionnaire>();
            if (DataStore.GetDataStoredJson("Questionnaires").ToList().Count > 0 & Source != "Focus")
            {
                var list = JsonConvert.DeserializeObject <List <Questionnaire_Model> >(DataStore.GetDataStoredJson("Questionnaires").ToList()[0].json);
                foreach (var questionnaire in list)
                {
                    foreach (var question in questionnaire.questions)
                    {
                        var data = new tmp_questionnaire
                        {
                            answers          = question.answers,
                            question         = question.question,
                            id_question      = question._id,
                            id_questionnaire = questionnaire._id,
                            title            = questionnaire.title
                        };
                        tmp_Questionnaires.Add(data);
                    }
                }
            }
            Selected_Products_To_Deliver = new ObservableCollection <object>();

            PresenteProductCommand = new Command(async() =>
            {
                await ExecuteOnPresenteProduct();
            });
            PresentedProductsListCommand = new Command(async() =>
            {
                await ExecuteOnPresenteProductsList();
            });
            AddVisiteCommand = new Command(async() =>
            {
                await ExecuteOnAddVisite();
            });
            QuestionnaireCommand = new Command(async() =>
            {
                await ExecuteOnQuestionnaire();
            });
            MessagingCenter.Subscribe <PresenteProductDoctor_ViewModel, tmp_presented_products_doctor>(this, "UpdatePresentedDoctor", (sender, args) =>
            {
                Tmp_Presented_Products_Doctor.Add(args);
                Products_Presented_Ids.Add(args.id_product);
                MessagingCenter.Send(this, "ListIdsUpdated", Products_Presented_Ids);
            });
            MessagingCenter.Subscribe <PresenteProductPharmacy_ViewModel, tmp_pretented_products_pharmacy>(this, "UpdatePresentedPharmacy", (sender, args) =>
            {
                Tmp_Pretented_Products_Pharmacies.Add(args);
                Products_Presented_Ids.Add(args.id_product);
                MessagingCenter.Send(this, "ListIdsUpdated", Products_Presented_Ids);
            });
            MessagingCenter.Subscribe <PresentedProductsList_ViewModel, tmp_presented_products_doctor>(this, "DeletePresentedDoctor", (sender, args) =>
            {
                Tmp_Presented_Products_Doctor.Remove(args);
                Products_Presented_Ids.Remove(args.id_product);
            });
            MessagingCenter.Subscribe <PresentedProductsList_ViewModel, tmp_pretented_products_pharmacy>(this, "DeletePresentedPharmacy", (sender, args) =>
            {
                Tmp_Pretented_Products_Pharmacies.Remove(args);
                Products_Presented_Ids.Remove(args.id_product);
            });
            MessagingCenter.Subscribe <Questionnaire_View, List <tmp_questionnaire> >(this, "QuestionnaireUpdate", (sender, args) =>
            {
                tmp_Questionnaires = args;
            });
            MessagingCenter.Subscribe <Visite_View, ObservableCollection <object> >(this, "SelectedItemsChanged", (sender, args) =>
            {
                Selected_Products_To_Deliver = args;
            });
        }