Exemplo n.º 1
0
        public ActionResult Create(TaxpayerIssuer item)
        {
            item.Regime = SatTaxRegime.TryFind(item.RegimeId);

            if (!string.IsNullOrEmpty(item.Id))
            {
                var entity = TaxpayerIssuer.TryFind(item.Id);

                if (entity != null)
                {
                    ModelState.AddModelError("", Resources.TaxpayerRecipientAlreadyExists);
                }
            }

            if (!ModelState.IsValid)
            {
                return(PartialView("_Create", item));
            }

            item.Id       = item.Id.ToUpper();
            item.Name     = string.IsNullOrWhiteSpace(item.Name) ? null : item.Name.Trim();
            item.Provider = FiscalCertificationProvider.ProFact;

            using (var scope = new TransactionScope()) {
                item.CreateAndFlush();
            }

            return(PartialView("_Refresh"));
        }
Exemplo n.º 2
0
        public ActionResult Edit(TaxpayerIssuer item)
        {
            item.Regime = SatTaxRegime.TryFind(item.RegimeId);

            if (!ModelState.IsValid)
            {
                return(PartialView("_Edit", item));
            }

            var entity = TaxpayerIssuer.Find(item.Id);

            entity.Name     = string.IsNullOrWhiteSpace(item.Name) ? null : item.Name.Trim();
            entity.Regime   = item.Regime;
            entity.Provider = item.Provider;

            using (var scope = new TransactionScope()) {
                entity.UpdateAndFlush();
            }

            return(PartialView("_Refresh"));
        }