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")); }
public ActionResult Details(string id) { var entity = TaxpayerIssuer.Find(id); if (Request.IsAjaxRequest()) { return(PartialView("_Details", entity)); } return(View(entity)); }
public ActionResult DeleteConfirmed(string id) { var item = TaxpayerIssuer.Find(id); try { using (var scope = new TransactionScope()) { item.DeleteAndFlush(); } } catch (GenericADOException ex) { System.Diagnostics.Debug.WriteLine(ex); return(PartialView("DeleteUnsuccessful")); } return(PartialView("_Refresh")); }
public ActionResult Create(Store item) { item.Taxpayer = TaxpayerIssuer.TryFind(item.TaxpayerId); item.Location = SatPostalCode.TryFind(item.LocationId); if (!ModelState.IsValid) { return(PartialView("_Create", item)); } using (var scope = new TransactionScope()) { item.ReceiptMessage = string.Format("{0}", item.ReceiptMessage).Trim(); item.Address.Create(); item.CreateAndFlush(); } return(PartialView("_Refresh")); }
public ActionResult Edit(Store item) { item.Taxpayer = TaxpayerIssuer.TryFind(item.TaxpayerId); item.Location = SatPostalCode.TryFind(item.LocationId); if (!ModelState.IsValid || item.Taxpayer == null) { return(PartialView("_Edit", item)); } var entity = Store.Find(item.Id); var address = entity.Address; entity.Code = item.Code; entity.Name = item.Name; entity.Taxpayer = item.Taxpayer; entity.Logo = item.Logo; entity.Location = item.Location; entity.ReceiptMessage = item.ReceiptMessage?.Trim(); using (var scope = new TransactionScope()) { if (!address.Equals(item.Address)) { entity.Address = item.Address; entity.Address.Create(); } entity.UpdateAndFlush(); } if (!address.Equals(item.Address)) { try { using (var scope = new TransactionScope()) { address.DeleteAndFlush(); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); } } return(PartialView("_Refresh")); }
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")); }
public ActionResult Edit(TaxpayerIssuer item) { if (!item.HasAddress) { ModelState.Where (x => x.Key.StartsWith ("Address.")).ToList ().ForEach (x => x.Value.Errors.Clear ()); item.Address = null; } if (!ModelState.IsValid) { return PartialView ("_Edit", item); } var entity = TaxpayerIssuer.Find (item.Id); var address = entity.Address; entity.HasAddress = (address != null); entity.Name = string.IsNullOrWhiteSpace (item.Name) ? null : item.Name.Trim (); entity.Regime = item.Regime.Trim (); entity.Scheme = item.Scheme; entity.Provider = item.Provider; using (var scope = new TransactionScope ()) { if (item.HasAddress) { entity.Address = item.Address; entity.Address.Create (); } else { entity.Address = null; } entity.UpdateAndFlush (); } if (address != null) { try { using (var scope = new TransactionScope ()) { address.DeleteAndFlush (); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine (ex); } } return PartialView ("_Refresh"); }
public ActionResult Create(TaxpayerIssuer item) { if (!string.IsNullOrEmpty (item.Id)) { var entity = TaxpayerIssuer.TryFind (item.Id); if (entity != null) { ModelState.AddModelError ("", Resources.TaxpayerRecipientAlreadyExists); } } if (!item.HasAddress) { ModelState.Where (x => x.Key.StartsWith ("Address.")).ToList ().ForEach (x => x.Value.Errors.Clear ()); item.Address = null; } if (!ModelState.IsValid) { return PartialView ("_Create", item); } item.Id = item.Id.ToUpper (); item.Name = string.IsNullOrWhiteSpace (item.Name) ? null : item.Name.Trim (); item.Regime = item.Regime.Trim (); using (var scope = new TransactionScope ()) { if (item.HasAddress) { item.Address.Create (); } item.CreateAndFlush (); } return PartialView ("_Refresh"); }
public ActionResult AddCertificate(TaxpayerCertificate item, IEnumerable <HttpPostedFileBase> files) { if (!ModelState.IsValid) { return(View(item)); } foreach (var file in files) { if (file != null && file.ContentLength > 0) { var name = file.FileName.ToLower(); if (name.EndsWith(".cer")) { item.CertificateData = FileToBytes(file); } else if (name.EndsWith(".key")) { item.KeyData = FileToBytes(file); item.KeyPassword = Encoding.UTF8.GetBytes(item.KeyPassword2); } } } if (!CFDHelpers.PrivateKeyTest(item.KeyData, item.KeyPassword)) { ModelState.AddModelError("KeyPassword", Resources.Validation_InvalidPassword); return(View(item)); } string sn = string.Empty; var cert = new X509Certificate2(item.CertificateData); foreach (var b in cert.GetSerialNumber()) { sn = (char)b + sn; } item.Id = sn.PadLeft(20, '0'); var entity = TaxpayerCertificate.Queryable.SingleOrDefault(x => x.Id == item.Id); if (entity == null) { entity = new TaxpayerCertificate(); } entity.Id = item.Id; entity.CertificateData = item.CertificateData; entity.KeyData = item.KeyData; entity.KeyPassword = item.KeyPassword; entity.NotBefore = cert.NotBefore; entity.NotAfter = cert.NotAfter; entity.Taxpayer = TaxpayerIssuer.Find(item.TaxpayerId); using (var scope = new TransactionScope()) { foreach (var x in entity.Taxpayer.Certificates) { x.IsActive = false; x.Update(); } entity.IsActive = true; entity.SaveAndFlush(); } return(RedirectToAction("Details", new { id = item.TaxpayerId })); }
public ActionResult Delete(string id) { var item = TaxpayerIssuer.Find(id); return(PartialView("_Delete", item)); }
public ActionResult Edit(string id) { var item = TaxpayerIssuer.Find(id); return(PartialView("_Edit", item)); }