public ActionResult AddEditTaxPercentage(Int32?TaxPercentageId, Int32?FatherId)
        {
            var model = new AddEditTaxPercentageViewModel();

            model.Fill(CargarDatosContext(), TaxPercentageId, FatherId);
            return(View(model));
        }
        public ActionResult AddEditTaxPercentage(AddEditTaxPercentageViewModel model)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    model.Fill(CargarDatosContext(), model.TaxPercentageId, model.FatherId);
                    TryUpdateModel(model);
                    PostMessage(MessageType.Error);
                    return(View(model));
                }

                TaxPercentage taxPercentage = null;

                if (model.TaxPercentageId.HasValue)
                {
                    taxPercentage = context.TaxPercentage.FirstOrDefault(x => x.TaxPercentageId == model.TaxPercentageId);
                }
                else
                {
                    taxPercentage       = new TaxPercentage();
                    taxPercentage.State = ConstantHelpers.ESTADO.ACTIVO;
                    context.TaxPercentage.Add(taxPercentage);
                }

                taxPercentage.Description = model.Description;

                context.SaveChanges();
                PostMessage(MessageType.Success);

                return(RedirectToAction("ListTaxPercentage", new { FatherId = model.FatherId }));
            }
            catch (Exception ex)
            {
                PostMessage(MessageType.Error);
                model.Fill(CargarDatosContext(), model.TaxPercentageId, model.FatherId);

                return(View(model));
            }
        }