/// <summary>
        /// Processes the upload excel.
        /// </summary>
        /// <param name="taxReportExcelFile">The tax report excel file.</param>
        /// <param name="taxReport">The tax report.</param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException">taxReportExcelFile</exception>
        public string ProcessUploadExcel(HttpPostedFileBase taxReportExcelFile, ITaxReportView taxReport)
        {
            if (taxReportExcelFile == null)
            {
                throw new ArgumentNullException(nameof(taxReportExcelFile));
            }

            var result = string.Empty;
            var taxReportCollection = this.agentOfDeductionRepository.ExcelUpload(taxReportExcelFile);

            try
            {
                foreach (DataRow r in taxReportCollection.Rows)
                {
                    var taxReportView = new TaxReportView()

                    {
                        BeneficiaryTIN = r.ItemArray[0].ToString(),

                        BVN          = r.ItemArray[1].ToString(),
                        IncomeAmount = decimal.Parse(r.ItemArray[2].ToString()),
                        TaxAmount    = decimal.Parse(r.ItemArray[3].ToString()),
                        Year         = taxReport.Year,
                        IncomeTypeId = taxReport.IncomeTypeId
                    };
                    result = this.agentOfDeductionRepository.SaveTaxReportInfo(taxReportView);
                }
            }
            catch
            {
                var ErrorFormat = "Invalid File Type";
                return(ErrorFormat);
            }


            return(result);
        }
        /// <summary>
        /// Saves the tax report information.
        /// </summary>
        /// <param name="taxReportView">The tax report view.</param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException">taxReportView</exception>
        /// <exception cref="Exception">Repository.Save. Db Entity Validation Exception. Data not saved. Error: " +
        ///                                         sb.ToString()</exception>
        public string SaveTaxReportInfo(ITaxReportView taxReportView)
        {
            var result = string.Empty;

            if (taxReportView == null)
            {
                throw new ArgumentNullException(nameof(taxReportView));
            }

            var taxReport = new TaxReport()

            {
                BeneficiaryTIN = taxReportView.BeneficiaryTIN,
                BVN            = taxReportView.BVN,
                IncomeAmount   = taxReportView.IncomeAmount,
                TaxAmount      = taxReportView.TaxAmount,
                IncomeTypeId   = taxReportView.IncomeTypeId,
                Year           = taxReportView.Year
            };

            try
            {
                using (
                    var dbContext = (PitalyticsEntities)this.dbContextFactory.GetDbContext())
                {
                    var taxReportInfo = dbContext.TaxReports.SingleOrDefault(x => x.BVN == taxReport.BVN && x.BeneficiaryTIN == taxReport.BeneficiaryTIN && x.IncomeAmount == taxReport.IncomeAmount &&
                                                                             x.TaxAmount == taxReport.TaxAmount && x.Year == taxReport.Year);
                    if (taxReportInfo == null)
                    {
                        dbContext.TaxReports.Add(taxReport);
                        dbContext.SaveChanges();
                    }
                }
            }


            catch (DbEntityValidationException e)
            {
                List <String> lstErrors = new List <string>();
                foreach (var eve in e.EntityValidationErrors)
                {
                    string msg = string.Format(
                        "Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                        eve.Entry.Entity.GetType().Name,
                        eve.Entry.State);

                    lstErrors.Add(msg);

                    foreach (var ve in eve.ValidationErrors)
                    {
                        msg = string.Format("- Property: \"{0}\", Error: \"{1}\"",
                                            ve.PropertyName, ve.ErrorMessage);
                        lstErrors.Add(msg);
                    }
                }

                if (lstErrors != null && lstErrors.Count() > 0)
                {
                    StringBuilder sb = new StringBuilder();
                    foreach (var item in lstErrors)
                    {
                        sb.Append(item + "; ");
                    }

                    throw new Exception("Repository.Save. Db Entity Validation Exception. Data not saved. Error: " +
                                        sb.ToString());
                }
            }

            catch (NotSupportedException e)
            {
            }
            return(result);
        }