Exemple #1
0
        public override void PerformTask3()
        {
            List <Store> csvFileStore = GetCSVFileStore(@"F:\ABACUA\Interview.csv");

            ParameterModel dataModel = new ParameterModel()
            {
                StartDate  = "2019-05-27",
                project_id = "roll-d-mobile-app",
                ReportType = true
            };

            List <Store> fromAPICSVFileStore = GetFromAPICSVStore(@"F:\ABACUA\FromAPI.csv", dataModel);

            /*try to remove 2 rows e.g. Roll'd - 140 William Street and Roll'd - Australia Square*/

            var recordOne = csvFileStore.First(s => s.Name == "Roll'd - 140 William Street");

            var recordTwo = csvFileStore.First(s => s.Name == "Roll'd - Australia Square");

            csvFileStore.Remove(recordOne);

            csvFileStore.Remove(recordTwo);

            ConvertStoreToCSV(csvFileStore, @"F:\ABACUA\Task3.csv");

            var recordOneFromAPI = fromAPICSVFileStore.First(s => s.Name == "Roll'd - 140 William Street");

            var recordTwoFromAPI = fromAPICSVFileStore.First(s => s.Name == "Roll'd - Australia Square");

            csvFileStore.Add(recordOneFromAPI);

            csvFileStore.Add(recordTwoFromAPI);

            ConvertStoreToCSV(csvFileStore, @"F:\ABACUA\Task3_After_Row_Added.csv");
        }
Exemple #2
0
        public override void PerformTask2()
        {
            List <Store> csvFileStore = GetCSVFileStore(@"F:\ABACUA\Interview.csv");

            ParameterModel dataModel = new ParameterModel()
            {
                StartDate  = "2019-05-28",
                project_id = "roll-d-mobile-app",
                ReportType = true
            };

            List <Store> fromAPICSVFileStore = GetFromAPICSVStore(@"F:\ABACUA\FromAPI.csv", dataModel);

            /* Update 28-May Data from API to CSV*/

            csvFileStore.ForEach(store =>
            {
                if (store.StoreValues.ContainsKey("28-05-2019"))
                {
                    store.StoreValues["28-05-2019"] = fromAPICSVFileStore.Where(s => s.Name == store.Name &&
                                                                                s.StoreValues.ContainsKey("28-05-2019")).Select(s => s.StoreValues["28-05-2019"]).FirstOrDefault();
                }
            });

            ConvertStoreToCSV(csvFileStore, @"F:\ABACUA\Task2.csv");
        }
Exemple #3
0
        public List <Store> GetFromAPICSVStore(string apiCSVFileLocation, ParameterModel dataModel)
        {
            APIClient client = new APIClient(_url, _apiKey);

            string apiCsvContent = client.GetDataFromAPI(dataModel).Result;

            File.WriteAllText(apiCSVFileLocation, apiCsvContent);

            string[] apiFileContent = File.ReadAllLines(apiCSVFileLocation);

            return(GetStores(apiFileContent));
        }
Exemple #4
0
        public override void PerformTask2()
        {
            List <Store> csvFileStore = GetCSVFileStore(@"C:\Users\pkakadiy\Downloads\Application\Base.csv");

            ParameterModel dataModel = new ParameterModel()
            {
                StartDate  = "2019-05-27",
                project_id = "roll-d-mobile-app",
                ReportType = true
            };

            List <Store> fromAPICSVFileStore = GetFromAPICSVStore(@"C:\Users\pkakadiy\Downloads\Application\FromAPI.csv", dataModel);

            /* Update 28-May Data from API to CSV*/

            csvFileStore.ForEach(store =>
            {
                if (!store.StoreValues.ContainsKey("28-06-2019"))
                {
                    var data = fromAPICSVFileStore.Where(s => s.Name == store.Name && s.StoreValues.ContainsKey("2019-06-28")).Select(s => s.StoreValues["2019-06-28"]).ToList();

                    KeyValuePair <string, string> TotalkeyValuePair = new KeyValuePair <string, string>();

                    TotalkeyValuePair = store.StoreValues.ElementAt(store.StoreValues.Count - 1);

                    store.StoreValues.Remove("Total");

                    if (data.Count > 0)
                    {
                        foreach (var item in data)
                        {
                            store.StoreValues.Add("28-06-2019", item);
                        }
                    }
                    else
                    {
                        store.StoreValues.Add("28-06-2019", "");
                    }

                    store.StoreValues.Add(TotalkeyValuePair.Key, TotalkeyValuePair.Value);
                }
            });

            ConvertStoreToCSV(csvFileStore, @"C:\Users\pkakadiy\Downloads\Application\Task2.csv");
        }