Beispiel #1
0
        public async Task <string> CreateEntities(List <MLFSAdvisor> advisors)
        {
            string response = "failure";

            DataTable salesTable      = new DataTable();
            DataTable incomeTable     = new DataTable();
            DataTable planTable       = new DataTable();
            DataTable commissionTable = new DataTable();

            foreach (IFormFile file in Files)
            {
                if (file.Length > 0)
                {
                    string newFilePath = Path.GetTempFileName();
                    using (var fileStream = new FileStream(newFilePath, FileMode.Create))
                    {
                        await file.CopyToAsync(fileStream);
                    }
                    if (file.FileName.Contains("MLFS Fees"))
                    {
                        salesTable = Tools.ConvertCSVToDataTable(newFilePath);
                    }
                    else if (file.FileName.Contains("Plans"))
                    {
                        planTable = Tools.ConvertCSVToDataTable(newFilePath);
                    }
                    else if (file.FileName.Contains("AdviserMonthlyFCI"))
                    {
                        incomeTable = Tools.ConvertCSVToDataTable(newFilePath);
                    }
                    else if (file.FileName.Contains("Commission"))
                    {
                        commissionTable = Tools.ConvertCSVToDataTable(newFilePath);
                    }
                    else
                    {
                        return(response);
                    }
                }
                else
                {
                    return(response);
                }
            }
            Sales    = MLFSSale.ConvertFromDataTable(salesTable, planTable, commissionTable, advisors, ReportingPeriod);
            Income   = MLFSIncome.CreateFromDataTable(incomeTable, advisors, ReportingPeriod);
            response = "Success";
            return(response);
        }
Beispiel #2
0
        public async Task <IActionResult> IncomeOnly(Upload upload)
        {
            if (upload.ReportingPeriodId == null)
            {
                return(NotFound());
            }
            MLFSReportingPeriod period = await _periodData.GetPeriodById((int)upload.ReportingPeriodId);

            if (period == null)
            {
                return(NotFound());
            }
            upload.ReportingPeriod   = period;
            upload.ReportingPeriodId = period.Id;
            if (upload.Files == null || upload.Files.Count != 4)
            {
                return(NotFound());
            }
            List <MLFSAdvisor> advisors = await _advisorData.GetAdvisors();

            DataTable incomeTable = new DataTable();

            foreach (IFormFile file in upload.Files)
            {
                if (file.Length > 0)
                {
                    string newFilePath = Path.GetTempFileName();
                    using (var fileStream = new FileStream(newFilePath, FileMode.Create))
                    {
                        await file.CopyToAsync(fileStream);
                    }
                    if (file.FileName.Contains("AdviserMonthlyFCI"))
                    {
                        incomeTable = Tools.ConvertCSVToDataTable(newFilePath);
                    }
                }
            }
            upload.Income = MLFSIncome.CreateFromDataTable(incomeTable, advisors, period);
            await _incomeData.InsertList(upload.Income);

            List <MLFSDebtorAdjustment> adjs = MLFSSale.CheckForReceipts(upload.Sales, upload.Income);

            _adjustmentData.InsertList(adjs);
            ViewBag.Result = "Uploaded Successfully";
            return(RedirectToAction("Index"));
        }