Пример #1
0
        public static async Task MergeUserIDS(CloudTable table, UserIDs us)
        {
            TableOperation isertorMerge = TableOperation.InsertOrMerge(us);
            TableResult    res          = await table.ExecuteAsync(isertorMerge);

            UserIDs asse = res.Result as UserIDs;
        }
Пример #2
0
        public async Task <JsonResult> SaveAssesment(string UserID,
                                                     string Mobile,
                                                     string Evaluation,
                                                     string LatBrowser,
                                                     string LongBrowser,
                                                     string LatPost,
                                                     string LongPost,
                                                     string Postal,
                                                     string Country,
                                                     string PreDiseases,
                                                     string Age,
                                                     string Fever,
                                                     string Cough,
                                                     string DryCough,
                                                     string Breath,
                                                     string BreathTimes,
                                                     string BreathResults,
                                                     string Condition,
                                                     string Administrative_area_level_5,
                                                     string Administrative_area_level_4,
                                                     string Administrative_area_level_3,
                                                     string Administrative_area_level_2,
                                                     string Administrative_area_level_1

                                                     )
        {
            CloudStorageAccount storageAccount;

            storageAccount = CloudStorageAccount.Parse(connectionString);
            CloudTableClient tableClient;

            tableClient = storageAccount.CreateCloudTableClient();
            int calculousuario = 0;

            if (string.IsNullOrEmpty(UserID))
            {
                CloudTable     table          = tableClient.GetTableReference(getTableUserIds());
                TableOperation tableOperation = TableOperation.Retrieve <UserIDs>("1", "1");
                TableResult    bh             = await table.ExecuteAsync(tableOperation);

                UserIDs usersids = bh.Result as UserIDs;
                usersids.IDACTUAL += 1;
                calculousuario     = usersids.IDACTUAL;

                MergeUserIDS(table, usersids).Wait();
            }
            else
            {
                calculousuario = int.Parse(UserID);
            }

            bool   MobileAss      = Mobile.Equals("true") ? true : false;
            int    EvaluationAss  = int.Parse(Evaluation);
            double LatBrowserAss  = double.Parse(LatBrowser, CultureInfo.InvariantCulture);
            double LongBrowserAss = double.Parse(LongBrowser, CultureInfo.InvariantCulture);
            double LatPostAss     = double.Parse(LatPost, CultureInfo.InvariantCulture);
            double LongPostAss    = double.Parse(LongPost, CultureInfo.InvariantCulture);
            string PostalAss      = Postal;
            string CountryAss     = Country;
            string PreDiseasesAss = PreDiseases;
            int    AgeAss         = Age.Equals("Age9") ? 9: Age.Equals("Age8")? 8 : Age.Equals("Age7") ? 7 : Age.Equals("Age6") ? 6 : Age.Equals("Age5") ? 5 :
                                    Age.Equals("Age4") ? 4 : Age.Equals("Age3") ? 3 : Age.Equals("Age2") ? 2 : 1;
            bool   FeverAss         = Fever.Equals("FeverYes") ? true : false;
            bool   CoughAss         = Cough.Equals("CoughYes") ? true : false;
            bool   DryCoughAss      = DryCough.Equals("DryCoughYes") ? true : false;
            int    BreathAss        = int.Parse(Breath);
            int    BreathTimesAss   = int.Parse(BreathTimes);
            int    BreathResultsAss = int.Parse(BreathResults);
            string ConditionAss     = Condition;

            string fecha     = DateTime.Now.Date.ToString("yyy-MM-dd");
            int    resultado = int.Parse(Evaluation);

            if (Administrative_area_level_5 == null)
            {
                Administrative_area_level_5 = "";
            }
            if (Administrative_area_level_4 == null)
            {
                Administrative_area_level_4 = "";
            }
            if (Administrative_area_level_3 == null)
            {
                Administrative_area_level_3 = "";
            }
            if (Administrative_area_level_2 == null)
            {
                Administrative_area_level_2 = "";
            }
            if (Administrative_area_level_1 == null)
            {
                Administrative_area_level_1 = "";
            }


            Assesment asses = new Assesment(calculousuario, fecha)
            {
                Mobile        = MobileAss,
                Evaluation    = EvaluationAss,
                LatBrowser    = LatBrowserAss,
                LongBrowser   = LongBrowserAss,
                LatPost       = LatPostAss,
                LongPost      = LongPostAss,
                Postal        = Postal,
                Country       = Country,
                PreDiseases   = PreDiseases,
                Age           = AgeAss,
                Fever         = FeverAss,
                Cough         = CoughAss,
                DryCough      = DryCoughAss,
                Breath        = BreathAss,
                BreathTimes   = BreathTimesAss,
                BreathResults = BreathResultsAss,
                Condition     = Condition,
                Administrative_area_level_5 = Administrative_area_level_5,
                Administrative_area_level_4 = Administrative_area_level_4,
                Administrative_area_level_3 = Administrative_area_level_3,
                Administrative_area_level_2 = Administrative_area_level_2,
                Administrative_area_level_1 = Administrative_area_level_1
            };

            string root = "";

            try
            {
                CloudTable table = tableClient.GetTableReference(getTableAssessments());
                MergeAssesment(table, asses).Wait();

                root = calculousuario.ToString();
            }

            catch (Exception e)
            {
                root = "";
            }

            return(Json(root));
        }