public static void InsertImportDistributor(ImportDistributor newValue) { CanonDataContext db = Cdb.Instance; db.ImportDistributors.InsertOnSubmit(newValue); db.SubmitChanges(); }
public bool ExportToDb() { ErrorMessages.Clear(); try { bool IsSucceeded = false; List <T> list = this.ImportFile(ref IsSucceeded); if (IsSucceeded == false) { return(false); } CanonDataContext db = Cdb.Instance; // Create ImportDistributor ImportDistributor importDistributor = new ImportDistributor(); importDistributor.IDDistributor = DistributorId; importDistributor.IDUser = WebVariables.LoggedUserId; importDistributor.FileName = _OriginalFilename; importDistributor.DateImported = DateTime.Now; importDistributor.DateFrom = DateTime.Now; importDistributor.DateTo = importDistributor.DateFrom.AddDays(30); importDistributor.ErrorMessage = string.Empty; importDistributor.Succeeded = true; importDistributor.IsDeleted = false; CanonImportDistributor.InsertImportDistributor(importDistributor); // import Distributor records foreach (T record in list) { try { record.ImportDistributor = importDistributor; record.InsertImportDistributorRecord(); } catch (Exception ex) { //add message about error ErrorMessages.Add(new ImportErrorMessage("GeneralRecordImportError", new string[] { "Reseller", record.ResellerIdentificationNumber + "_" + record.ResellerName })); //into log WebVariables.Logger.Error(string.Format("File {0}, general import error", _filename), ex); } } } catch (Exception ex) { ErrorMessages.Add(new ImportErrorMessage("GeneralFileImportError")); //into log WebVariables.Logger.Error(string.Format("File {0} ", _filename), ex); return(false); } return(true); }
public static void RemoveImportDistributor(int id) { CanonDataContext db = Cdb.Instance; ImportDistributor import = db.ImportDistributors.FirstOrDefault(d => d.ID == id); if (import != null) { import.IsDeleted = true; db.SubmitChanges(); } }
public static void InsertImportDistributor(ImportDistributor newValue) { CanonDataContext db = Cdb.Instance; db.ImportDistributors.InsertOnSubmit(newValue); db.SubmitChanges(); }