public ActionResult AplicarCambiosCtasDepto(string ctasSelected)
        {
            IRepositoryWrapper _repo = new RepositoryWrapper();
            var config = _repo.Configuracion.GetCtasGastos();

            string[] ctas = new string[] { };

            if (!string.IsNullOrEmpty(ctasSelected))
            {
                ctas = ctasSelected.Split(',');
            }
            if (string.IsNullOrWhiteSpace(ctasSelected))
            {
                //if (ctasSelected == null)
                ctasSelected = config.Valor;
                //else
                //    ctasSelected = "";
            }

            config.Valor = ctasSelected;

            var result = _repo.Configuracion.AddUpdate(config);

            if (!result.Item1)
            {
                ViewBag.ErrorMessage = string.Join(Environment.NewLine, result.Item2);
            }

            var model = new CuentasDeptoViewModel();

            string[] ctaDepto = ctasSelected.Split(',').ToArray();
            model.CtasSelected = ctaDepto.Select(short.Parse).ToArray();

            ViewData["CtasDeptoItems"] = _repo.CuentasDepartamento.GetCuentasDepartamentos();

            //return View(model);
            // CUANDO SE USA AJAX PARA ACTUALIZAR
            return(new HttpStatusCodeResult(HttpStatusCode.OK));
        }
        public async Task <ActionResult> CuentasDepartamentos()
        {
            IRepositoryWrapper _repo = new RepositoryWrapper();
            await _repo.CuentasDepartamento.AgregarCuentasFromDWH_ResultadoGastosAsync();

            var model = new CuentasDeptoViewModel();
            var ctas  = await _repo.Configuracion.GetCtasGastosAsync();

            string[] ctaDepto = ctas.Valor.Split(',').ToArray();
            if (!string.IsNullOrWhiteSpace(ctas.Valor))
            {
                model.CtasSelected = ctaDepto.Select(short.Parse).ToArray();
            }
            else
            {
                model.CtasSelected = new short[] { }
            };

            ViewData["CtasDeptoItems"] = await _repo.CuentasDepartamento.GetCuentasDepartamentosAsync();


            return(View(model));
        }