Exemple #1
0
        public static async Task <List <HistoryModel> > LoadHistoryAsync(string view)
        {
            HistoryModel history = new HistoryModel();
            string       sql     = "SELECT * FROM recent_activities";

            var result = await DataAccess.LoadDataList <HistoryModel, dynamic>(sql, history, connectionString);

            if (result != null)
            {
                foreach (var i in result)
                {
                    int index = result.FindIndex(rs => rs.CaseId.Equals(i.CaseId, StringComparison.Ordinal));

                    string vhtinfo = $"SELECT * FROM vht_info WHERE VHTCode='{i.VHTCode}'";
                    var    vht     = await DataAccess.LoadData <ResponseViewModel, dynamic>(vhtinfo, new { }, connectionString);

                    result[index].VHTName  = vht.Fullname;
                    result[index].VHTPhone = vht.Phone;

                    string emtinfo = $"SELECT TeamId,Transporter,Phone,Type FROM emergency_teams WHERE TeamId='{i.EMTCode}'";
                    var    emt     = await DataAccess.LoadData <EMTInfo, dynamic>(emtinfo, new { }, connectionString);

                    if (emt != null)
                    {
                        result[index].EMTName  = emt.Transporter;
                        result[index].EMTPhone = emt.Phone;
                    }

                    string medicalinfo = $"SELECT ID,Phone,Fullname,Status,Category FROM medical_officers WHERE ID='{i.CHWCode}'";
                    var    chw         = await DataAccess.LoadData <MedicalInfo, dynamic>(sql, new { }, connectionString);

                    if (chw != null)
                    {
                        result[index].CHWName  = chw.Fullname;
                        result[index].CHWPhone = chw.Phone;
                    }
                }
            }


            return(result);
        }
Exemple #2
0
        private async void ListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ListView view   = sender as ListView;
            string   value  = view.SelectedValue.ToString().Split(": ")[1];
            string   CaseID = view.Tag.ToString();

            if (value == "Reinstate case")
            {
                int index = historyContext.Items.FindIndex(ag => ag.CaseId.Equals(CaseID, StringComparison.Ordinal));
                if (historyContext.Items[index].Status != "Reinstated")
                {
                    var alert = new CasesModel()
                    {
                        CaseId      = CaseID,
                        DateTime    = DateTime.Now,
                        Location    = historyContext.Items[index].Location,
                        VHTCode     = historyContext.Items[index].VHTCode,
                        Description = historyContext.Items[index].Description,
                        Village     = historyContext.Items[index].Village,
                        Status      = "pending"
                    };

                    await sService.ReinstateCase(alert);

                    historyContext.RefreshList();
                }
                else
                {
                    MessageBox.Show("Failed! Already reinstated");
                }
            }
            else if (value == "Details")
            {
                int index = historyContext.Items.FindIndex(ag => ag.CaseId.Equals(CaseID, StringComparison.Ordinal));

                HistoryModel hItem = new HistoryModel();
                hItem = historyContext.Items[index];

                historyItem?.Invoke(hItem);
            }
        }