public ActionResult SaveChangeset(TakeRateParameters parameters)
        {
            TakeRateParametersValidator
            .ValidateTakeRateParameters(DataContext, parameters,
                                        TakeRateParametersValidator.TakeRateIdentifierWithChangeset);

            CheckModelAllowsEdit(parameters);

            var business = new TakeRateBusiness(DataContext, parameters);

            business.CalculateChanges();
            business.SaveChangeset();

            return(Json(business.CurrentChangeSet));
        }
        public async Task <ActionResult> GetValidation(TakeRateParameters parameters)
        {
            TakeRateParametersValidator.ValidateTakeRateParameters(DataContext, parameters, TakeRateParametersValidator.TakeRateIdentifier);

            var validation = new FdpValidation();

            if (parameters.MarketId.HasValue)
            {
                var business = new TakeRateBusiness(DataContext, parameters);
                business.ValidateChangeset();

                validation = await DataContext.TakeRate.GetValidation(TakeRateFilter.FromTakeRateParameters(parameters));
            }

            return(Json(validation));
        }
        public void ExportChangeDetails(TakeRateParameters parameters)
        {
            TakeRateParametersValidator.ValidateTakeRateParameters(DataContext, parameters, TakeRateParametersValidator.TakeRateIdentifierWithChangeset);

            var business   = new TakeRateBusiness(DataContext, parameters);
            var exportData = business.ExportChangeset();

            Response.ClearContent();
            Response.Buffer = true;
            Response.AddHeader("content-disposition", "attachment; filename=ChangeHistory.xlsx");
            Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";

            using (var stream = new MemoryStream())
            {
                exportData.SaveAs(stream);
                stream.WriteTo(Response.OutputStream);
                Response.Flush();
                Response.End();
            }
        }
        public void ExportCpat(TakeRateParameters parameters)
        {
            var business   = new TakeRateBusiness(DataContext, parameters, false);
            var exportData = business.ExportCpat();
            var fileName   = string.Format("TakeRateCpatExport_{0:yyyyMMdd}_{1}.xlsx",
                                           DateTime.Now,
                                           parameters.TakeRateId);

            Response.ClearContent();
            Response.Buffer = true;
            Response.AddHeader("content-disposition", "attachment; filename=" + fileName);
            Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";

            using (var stream = new MemoryStream())
            {
                exportData.SaveAs(stream);
                stream.WriteTo(Response.OutputStream);
                Response.Flush();
                Response.End();
            }
        }
	    public async Task<ActionResult> GetValidation(TakeRateParameters parameters)
	    {
	        TakeRateParametersValidator.ValidateTakeRateParameters(DataContext, parameters, TakeRateParametersValidator.TakeRateIdentifier);

            var validation = new FdpValidation();

	        if (parameters.MarketId.HasValue)
	        {
	            var business = new TakeRateBusiness(DataContext, parameters);
	            business.ValidateChangeset();

                validation = await DataContext.TakeRate.GetValidation(TakeRateFilter.FromTakeRateParameters(parameters));
	        }

	        return Json(validation);
	    }
        public void ExportChangeDetails(TakeRateParameters parameters)
        {
            TakeRateParametersValidator.ValidateTakeRateParameters(DataContext, parameters, TakeRateParametersValidator.TakeRateIdentifierWithChangeset);

            var business = new TakeRateBusiness(DataContext, parameters);
            var exportData = business.ExportChangeset();

            Response.ClearContent();
            Response.Buffer = true;
            Response.AddHeader("content-disposition", "attachment; filename=ChangeHistory.xlsx");
            Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";

            using (var stream = new MemoryStream())
            {
                exportData.SaveAs(stream);
                stream.WriteTo(Response.OutputStream);
                Response.Flush();
                Response.End();
            }        
        }
        public void ExportCpat(TakeRateParameters parameters)
        {
            var business = new TakeRateBusiness(DataContext, parameters, false);
            var exportData = business.ExportCpat();
            var fileName = string.Format("TakeRateCpatExport_{0:yyyyMMdd}_{1}.xlsx",
                DateTime.Now,
                parameters.TakeRateId);

            Response.ClearContent();
            Response.Buffer = true;
            Response.AddHeader("content-disposition", "attachment; filename=" + fileName);
            Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";

            using (var stream = new MemoryStream())
            {
                exportData.SaveAs(stream);
                stream.WriteTo(Response.OutputStream);
                Response.Flush();
                Response.End();
            }
        }
        public ActionResult SaveChangeset(TakeRateParameters parameters)
        {
            TakeRateParametersValidator
                .ValidateTakeRateParameters(DataContext, parameters,
                    TakeRateParametersValidator.TakeRateIdentifierWithChangeset);

            CheckModelAllowsEdit(parameters);

            var business = new TakeRateBusiness(DataContext, parameters);
            
            business.CalculateChanges();
            business.SaveChangeset();

            return Json(business.CurrentChangeSet);
        }