/**
         * TODO: Refactor
         */

        public ActionResult AddFile(HttpPostedFileBase file)
        {
            // Get the current resource root file
            string resourceFileLocation = ConfigurationManager.BaseLocation + ConfigurationManager.FileName;
            TransactionAdapterType type = ConfigurationManager.FileType;

            // Push some data to the view
            ViewData["ResourceFolder"] = resourceFileLocation;
            ViewData["ResourceType"]   = type.ToString();
            ViewData["NumRecords"]     = RecordRetriever.GetAllBankRecords().Count();
            ViewData["NumLines"]       = System.IO.File.ReadLines(resourceFileLocation).Count();

            // Save the uploaded file to the /Uploaded/ dir
            string path = System.IO.Path.Combine(ConfigurationManager.BaseLocation, "Uploaded/" + DateTime.Now.Ticks + "_" + System.IO.Path.GetFileName(file.FileName));

            file.SaveAs(path);

            // Some more data on the new file
            ViewData["NewFileNumLines"]   = System.IO.File.ReadLines(path).Count();
            ViewData["NewFileNumRecords"] = RecordRetriever.GetBankRecordsByUploadPerUser(path, User.Identity.Name);

            // Merge uploaded file with the root file (which will make an automatic back-up as well)
            CSVMerger.MergeFiles(resourceFileLocation, path);

            // And some more data on the merged files
            ViewData["CombinedFileNumLines"]   = System.IO.File.ReadLines(resourceFileLocation).Count();
            ViewData["CombinedFileNumRecords"] = RecordRetriever.GetBankRecordsByUser(User.Identity.Name);

            return(View());
        }
 public static TransactionAdapter GetAdapter(TransactionAdapterType type)
 {
     switch (type)
     {
         case TransactionAdapterType.RABOBANK:
             return new TransactionAdapterRabobank();
         case TransactionAdapterType.ING:
             return new TransactionAdapterING();
         default:
             return null;
     }
 }
        public static TransactionAdapter GetAdapter(TransactionAdapterType type)
        {
            switch (type)
            {
            case TransactionAdapterType.RABOBANK:
                return(new TransactionAdapterRabobank());

            case TransactionAdapterType.ING:
                return(new TransactionAdapterING());

            default:
                return(null);
            }
        }
        /**
         * Updates the root file type
         **/

        public ActionResult UpdateRootFileType(string newResourceType)
        {
            // Get current and parse new type
            TransactionAdapterType currentType = ConfigurationManager.FileType;
            TransactionAdapterType newType     = (TransactionAdapterType)Enum.Parse(typeof(TransactionAdapterType), newResourceType);

            // Check equality
            if (!currentType.Equals(newType))
            {
                // Save type to settings
                ConfigurationManager.UpdateSettingValue(ConfigurationManager.FileTypeKey, newType);
            }

            // Display index
            return(RedirectToAction("Index"));
        }