public int UpdateParty(PartyAcctDetails party) { try { using (_dbContext = string.IsNullOrEmpty(_connectionString) ? _dbContext : new ZionContext(_connectionString)) { _dbContext.Entry(party).State = EntityState.Modified; if (party.Status == "Inactive") //Deactivate all the dependent objects { InterfaceMasterDataAccess interfaceDAL = new InterfaceMasterDataAccess(_connectionString); List <InterfaceMaster> interfaces = _dbContext.InterfaceMaster.Where(intf => intf.PartyId == party.PartyId && intf.Status != "Inactive").ToList(); if (interfaces != null && interfaces.Count > 0) { _dbContext.AttachRange(interfaces); interfaces.ForEach(intf => { intf.Status = party.Status; interfaceDAL.UpdateInterfaceHeirarchyStatus(_dbContext, intf.InterfaceId, "Inactive"); }); } } _dbContext.SaveChanges(); return(1); } } catch { throw; } }
public int UpdateDataSetDBDetailsByDataSetID(DatasetTableDetails datasetTableDetails) { try { using (_dbContext = string.IsNullOrEmpty(_connectionString) ? _dbContext : new ZionContext(_connectionString)) { DatasetTableDetails record = _dbContext.DatasetTableDetails.Where(i => i.DatasetId == datasetTableDetails.DatasetId).FirstOrDefault(); if (record != null) { record.FullLoadQuery = datasetTableDetails.FullLoadQuery; record.DeltaLoadQuery = datasetTableDetails.DeltaLoadQuery; record.UpdatedDate = datasetTableDetails.UpdatedDate; record.UpdatedBy = datasetTableDetails.UpdatedBy; } _dbContext.Entry(record).State = EntityState.Modified; _dbContext.SaveChanges(); return(1); } } catch { throw; } }
public int UpdateInterfaceSftpDetailsByInterfaceId(InterfaceSftpDetails interfaceSftpDetails) { try { using (_dbContext = string.IsNullOrEmpty(_connectionString) ? _dbContext : new ZionContext(_connectionString)) { InterfaceSftpDetails record = _dbContext.InterfaceSftpDetails.Where(i => i.InterfaceId == interfaceSftpDetails.InterfaceId).FirstOrDefault(); if (record != null) { record.HostName = interfaceSftpDetails.HostName; record.UserName = interfaceSftpDetails.UserName; record.Password = interfaceSftpDetails.Password; record.Port = interfaceSftpDetails.Port; record.SshKey = interfaceSftpDetails.SshKey; record.Passphrase = interfaceSftpDetails.Passphrase; record.UpdatedDate = interfaceSftpDetails.UpdatedDate; record.UpdatedBy = interfaceSftpDetails.UpdatedBy; } _dbContext.Entry(record).State = EntityState.Modified; _dbContext.SaveChanges(); return(1); } } catch { throw; } }
public int UpdateDataSetSftpDetailsByDataSetID(DatasetFileDetails datasetFileDetails) { try { using (_dbContext = string.IsNullOrEmpty(_connectionString) ? _dbContext : new ZionContext(_connectionString)) { DatasetFileDetails record = _dbContext.DatasetFileDetails.Where(i => i.DatasetId == datasetFileDetails.DatasetId).FirstOrDefault(); if (record != null) { record.FullFileName = datasetFileDetails.FullFileName; record.DeltaFileName = datasetFileDetails.DeltaFileName; record.FolderLocation = datasetFileDetails.FolderLocation; record.FileExtension = datasetFileDetails.FileExtension; record.FileDelimiter = datasetFileDetails.FileDelimiter; record.UpdatedDate = datasetFileDetails.UpdatedDate; record.UpdatedBy = datasetFileDetails.UpdatedBy; record.ArchiveLocation = datasetFileDetails.ArchiveLocation; record.ContainsHeader = datasetFileDetails.ContainsHeader; record.ContainsTrailer = datasetFileDetails.ContainsTrailer; record.ArchiveOutboundFile = datasetFileDetails.ArchiveOutboundFile; } _dbContext.Entry(record).State = EntityState.Modified; _dbContext.SaveChanges(); return(1); } } catch { throw; } }
public int UpdateDatasetMaster(DatasetMaster datasetMaster) { int datasetId = datasetMaster.DatasetId; string status = datasetMaster.Status; try { using (_dbContext = string.IsNullOrEmpty(_connectionString) ? _dbContext : new ZionContext(_connectionString)) { _dbContext.Entry(datasetMaster).State = EntityState.Modified; //Update the status of heirarchy IngestionDataAccess ingestionDAL = new IngestionDataAccess(_connectionString); ingestionDAL.MappingStatusUpdateForDatasetId(_dbContext, datasetId, status == "Active"?true:false); ingestionDAL.TempMappingStatusUpdateForDatasetId(_dbContext, datasetId, status == "Active" ? true : false); OutgestionDataAccess outgestionDAL = new OutgestionDataAccess(_connectionString); outgestionDAL.OutgestionStatusUpdateForDatasetId(_dbContext, datasetId, status == "Active" ? true : false); _dbContext.SaveChanges(); } return(1); } catch { throw; } }
public void CreateOutboundResendAudit(List <OutboundFileResendAudit> outboundFileResendAudit) { using (_dbContext = string.IsNullOrEmpty(_connectionString) ? _dbContext : new ZionContext(_connectionString)) { _dbContext.OutboundFileResendAudit.AddRange(outboundFileResendAudit); _dbContext.SaveChanges(); } }
public void AddTemplate(TemplateMaster template, List <TemplateDetails> templateColumns) { try { using (_dbContext = string.IsNullOrEmpty(_connectionString) ? _dbContext : new ZionContext(_connectionString)) { _dbContext.TemplateMaster.Add(template); _dbContext.SaveChanges(); int id = template.TemplateId; templateColumns.ForEach(tc => tc.TemplateId = id); _dbContext.TemplateDetails.AddRange(templateColumns); _dbContext.SaveChanges(); } } catch { throw; } }
public void UpdateLoginAuditDetails(string userId) { using (_dbContext = string.IsNullOrEmpty(_connectionString) ? _dbContext : new ZionContext(_connectionString)) { var record = _dbContext.LoginAuditDetails.Where(x => x.LoginDate != null && x.LogoutDate == null && x.UserId == userId).OrderByDescending(z => z.Id).FirstOrDefault(); if (record != null) { record.LogoutDate = DateTime.UtcNow; _dbContext.SaveChanges(); } } }
public void AddLoginAuditDetails(string userId, string status, string failureReason) { using (_dbContext = string.IsNullOrEmpty(_connectionString) ? _dbContext : new ZionContext(_connectionString)) { LoginAuditDetails newRecord = new LoginAuditDetails(); newRecord.UserId = userId; newRecord.LoginDate = (status == "Failed") ? (DateTime?)null : DateTime.UtcNow; newRecord.Status = status; newRecord.FailureReason = failureReason; _dbContext.LoginAuditDetails.Add(newRecord); _dbContext.SaveChanges(); } }
public void AddDatasetSchedulingDetails(List <DatasetSchedulingDetails> schedulingDetails) { using (_dbContext = string.IsNullOrEmpty(_connectionString) ? _dbContext : new ZionContext(_connectionString)) { foreach (DatasetSchedulingDetails s in schedulingDetails) { if (s != null) { _dbContext.DatasetSchedulingDetails.Add(s); } } _dbContext.SaveChanges(); } }
public int AddDataset(DatasetMaster datasetMaster) { try { using (_dbContext = string.IsNullOrEmpty(_connectionString) ? _dbContext : new ZionContext(_connectionString)) { _dbContext.DatasetMaster.Add(datasetMaster); _dbContext.SaveChanges(); return(_dbContext.DatasetMaster.Max(d => d.DatasetId)); } } catch { throw; } }
public int AddCustomer(CustomerAcctDetails customer) { try { using (_dbContext = string.IsNullOrEmpty(_connectionString) ? _dbContext : new ZionContext(_connectionString)) { _dbContext.CustomerAcctDetails.Add(customer); _dbContext.SaveChanges(); return(1); } } catch { throw; } }
public int AddDatasetFileDetails(DatasetFileDetails datasetFileDetails) { try { using (_dbContext = string.IsNullOrEmpty(_connectionString) ? _dbContext : new ZionContext(_connectionString)) { _dbContext.DatasetFileDetails.Add(datasetFileDetails); _dbContext.SaveChanges(); return(_dbContext.DatasetFileDetails.Max(d => d.DatasetDetailId)); } } catch { throw; } }
public int AddInterfaceSftpDetails(InterfaceSftpDetails interfaceSftpDetails) { try { using (_dbContext = string.IsNullOrEmpty(_connectionString) ? _dbContext : new ZionContext(_connectionString)) { _dbContext.InterfaceSftpDetails.Add(interfaceSftpDetails); _dbContext.SaveChanges(); return(_dbContext.InterfaceSftpDetails.Max(i => i.InterfaceSftpId)); } } catch { throw; } }
public int AddParty(PartyAcctDetails party) { try { using (_dbContext = string.IsNullOrEmpty(_connectionString) ? _dbContext : new ZionContext(_connectionString)) { _dbContext.PartyAcctDetails.Add(party); _dbContext.SaveChanges(); return(1); } } catch { throw; } }
public int AddInterface(InterfaceMaster interfaceMaster) { try { using (_dbContext = string.IsNullOrEmpty(_connectionString) ? _dbContext : new ZionContext(_connectionString)) { _dbContext.InterfaceMaster.Add(interfaceMaster); _dbContext.SaveChanges(); return(_dbContext.InterfaceMaster.Max(i => i.InterfaceId)); } } catch { throw; } }
public int UpdateDatasetFileDetails(DatasetFileDetails datasetFileDetails) { try { using (_dbContext = string.IsNullOrEmpty(_connectionString) ? _dbContext : new ZionContext(_connectionString)) { _dbContext.Entry(datasetFileDetails).State = EntityState.Modified; _dbContext.SaveChanges(); return(1); } } catch { throw; } }
public void SubmitMappingDetails(List <LandingToCoreMapDetails> mapDetails, int dataSetId) { try { using (_dbContext = string.IsNullOrEmpty(_connectionString) ? _dbContext : new ZionContext(_connectionString)) { //Build and retrieve temp table values List <LandingToCoreTempDetails> tempSavedDetails = (from tempRecord in _dbContext.LandingToCoreTempDetails where (tempRecord.DatasetId == dataSetId) select tempRecord ).ToList(); //Todo: Is StagingCoreId enough? //Delete from temp table for this mapping (identified via DataSetId/LandingTable) _dbContext.LandingToCoreTempDetails.RemoveRange(tempSavedDetails); //Delete all existing records and insert all records as passed? List <LandingToCoreMapDetails> existingRecords = _dbContext.LandingToCoreMapDetails.Where(x => x.DatasetId == dataSetId).ToList(); string createdBy = mapDetails[0].CreatedBy; string updatedBy = ""; DateTime?createdDate = DateTime.Now; DateTime?updatedDate = null; if (existingRecords.Count > 0) { var rec = existingRecords[0]; createdBy = rec.CreatedBy; createdDate = rec.CreatedDate; updatedDate = DateTime.Now; updatedBy = mapDetails[0].UpdatedBy; } _dbContext.LandingToCoreMapDetails.RemoveRange(existingRecords); mapDetails.ForEach(r => { r.CreatedBy = createdBy; r.CreatedDate = createdDate; r.UpdatedBy = updatedBy; r.UpdatedDate = updatedDate; }); _dbContext.LandingToCoreMapDetails.AddRange(mapDetails); _dbContext.SaveChanges(); //ToDo: Once successfully mapping saving backend system shall move available data from landing to the ZION core table as per the mapping provided by end user. } } catch { throw; } }
public int DeleteParty(int id) { try { using (_dbContext = string.IsNullOrEmpty(_connectionString) ? _dbContext : new ZionContext(_connectionString)) { PartyAcctDetails party = _dbContext.PartyAcctDetails.Find(id); _dbContext.PartyAcctDetails.Remove(party); _dbContext.SaveChanges(); return(1); } } catch { throw; } }
public int DeleteInterfaceSftpDetails(int id) { try { using (_dbContext = string.IsNullOrEmpty(_connectionString) ? _dbContext : new ZionContext(_connectionString)) { InterfaceSftpDetails interfaceSftpDetails = _dbContext.InterfaceSftpDetails.Find(id); _dbContext.InterfaceSftpDetails.Remove(interfaceSftpDetails); _dbContext.SaveChanges(); return(1); } } catch { throw; } }
public int DeleteLoginAuditDetails(string userId) { try { using (_dbContext = string.IsNullOrEmpty(_connectionString) ? _dbContext : new ZionContext(_connectionString)) { LoginAuditDetails loginAuditDetails = _dbContext.LoginAuditDetails.Find(userId); _dbContext.LoginAuditDetails.Remove(loginAuditDetails); _dbContext.SaveChanges(); return(1); } } catch { throw; } }
public int DeleteInterfaceMaster(int id) { try { using (_dbContext = string.IsNullOrEmpty(_connectionString) ? _dbContext : new ZionContext(_connectionString)) { InterfaceMaster interfaceMaster = _dbContext.InterfaceMaster.Find(id); _dbContext.InterfaceMaster.Remove(interfaceMaster); _dbContext.SaveChanges(); } return(1); } catch { throw; } }
public int UpdateInterfaceDbDetails(InterfaceDbDetails interfaceDbDetails) { try { using (_dbContext = string.IsNullOrEmpty(_connectionString) ? _dbContext : new ZionContext(_connectionString)) { _dbContext.Entry(interfaceDbDetails).State = EntityState.Modified; _dbContext.SaveChanges(); } return(1); } catch { throw; } }
public int DeleteDatasetFileDetails(int id) { try { using (_dbContext = string.IsNullOrEmpty(_connectionString) ? _dbContext : new ZionContext(_connectionString)) { DatasetFileDetails datasetFileDetails = _dbContext.DatasetFileDetails.Find(id); _dbContext.DatasetFileDetails.Remove(datasetFileDetails); _dbContext.SaveChanges(); return(1); } } catch { throw; } }
public int DeleteCustomer(int id) { try { using (_dbContext = string.IsNullOrEmpty(_connectionString) ? _dbContext : new ZionContext(_connectionString)) { CustomerAcctDetails emp = _dbContext.CustomerAcctDetails.Find(id); _dbContext.CustomerAcctDetails.Remove(emp); _dbContext.SaveChanges(); return(1); } } catch { throw; } }
public void CancelMapping(int datasetId) { try { using (_dbContext = string.IsNullOrEmpty(_connectionString) ? _dbContext : new ZionContext(_connectionString)) { List <LandingToCoreTempDetails> tempSavedDetails = (from tempRecord in _dbContext.LandingToCoreTempDetails where (tempRecord.DatasetId == datasetId) select tempRecord ).ToList(); //Delete from temp table for this mapping (identified via DataSetId) _dbContext.LandingToCoreTempDetails.RemoveRange(tempSavedDetails); _dbContext.SaveChanges(); } } catch { throw; } }
public void SaveMappingDetails(List <LandingToCoreTempDetails> mapDetails, int datasetId, string coreTableName) { try { using (_dbContext = string.IsNullOrEmpty(_connectionString) ? _dbContext : new ZionContext(_connectionString)) { //Delete all existing records and insert all records as passed for selected core table List <LandingToCoreTempDetails> existingRecords = (from tempRecord in _dbContext.LandingToCoreTempDetails join C in _dbContext.CoreTableDetails on tempRecord.CoreDetailId equals C.CoreDetailId where (tempRecord.DatasetId == datasetId && C.TableName == coreTableName) select tempRecord ).ToList(); _dbContext.LandingToCoreTempDetails.RemoveRange(existingRecords); _dbContext.LandingToCoreTempDetails.AddRange(mapDetails); _dbContext.SaveChanges(); } } catch { throw; } }
public int UpdateInterfaceMaster(InterfaceMaster interfaceMaster) { try { using (_dbContext = string.IsNullOrEmpty(_connectionString) ? _dbContext : new ZionContext(_connectionString)) { _dbContext.Entry(interfaceMaster).State = EntityState.Modified; if (interfaceMaster.Status.ToLower() == "inactive") { UpdateInterfaceHeirarchyStatus(_dbContext, interfaceMaster.InterfaceId, "Inactive"); } _dbContext.SaveChanges(); } return(1); } catch { throw; } }
public void UpdateDatasetSchedulingDetails(List <DatasetSchedulingDetails> schedulingDetails) { using (_dbContext = new ZionContext(_connectionString)) { int counter = 0; foreach (DatasetSchedulingDetails s in schedulingDetails) { counter++; int datasetId = schedulingDetails.Where(x => x != null).Select(d => d.DatasetId).FirstOrDefault(); if (s != null && s.DatasetDetailsId != 0) { _dbContext.Entry(s).State = EntityState.Modified; } else if (s != null && s.DatasetDetailsId == 0) { _dbContext.DatasetSchedulingDetails.Add(s); } else if (s == null && counter == 1) { DatasetSchedulingDetails sDetails = _dbContext.DatasetSchedulingDetails.Where(d => d.DatasetId == datasetId && d.LoadType.ToLower() == "full").FirstOrDefault(); if (sDetails != null) { _dbContext.DatasetSchedulingDetails.Remove(sDetails); } } else if (s == null && counter == 2) { DatasetSchedulingDetails sDetails = _dbContext.DatasetSchedulingDetails.Where(d => d.DatasetId == datasetId && d.LoadType.ToLower() == "delta").FirstOrDefault(); if (sDetails != null) { _dbContext.DatasetSchedulingDetails.Remove(sDetails); } } } _dbContext.SaveChanges(); } }
public void UpdateTemplate(TemplateMaster template) //List<TemplateDetails> templateColumns { try { using (_dbContext = string.IsNullOrEmpty(_connectionString) ? _dbContext : new ZionContext(_connectionString)) { var entity = _dbContext.TemplateMaster.Where(t => t.TemplateId == template.TemplateId).FirstOrDefault(); entity.TemplateName = template.TemplateName; entity.Status = template.Status; entity.UpdatedBy = template.UpdatedBy; entity.UpdatedDate = template.UpdatedDate; _dbContext.TemplateMaster.Update(entity); #region //code_for_update template columns ////get all existing records //List<TemplateDetails> existingRecords = (from existCols in _dbContext.TemplateDetails // where (existCols.TemplateId == template.TemplateId) // select existCols).ToList(); ////delete removed records //List<TemplateDetails> deleteRecords = existingRecords.Where(ex => { // var found = templateColumns.Where(t => t.TemplateDetailId == ex.TemplateDetailId).FirstOrDefault(); // if (found != null) return false; else return true; //}).ToList(); ////delete records from outgestion maping also //OutgestionDataAccess outgestion = new OutgestionDataAccess(_connectionString); //if (deleteRecords.Count > 0) //{ // outgestion.DeleteMapRecordForTemplateId(_dbContext, deleteRecords); // _dbContext.SaveChanges(); //} ////Delete record(s) for given template Id //_dbContext.RemoveRange(deleteRecords); ////Modify/Add records //templateColumns.ForEach(x => { // var existingRecord = existingRecords.Where(y => y.TemplateDetailId == x.TemplateDetailId).FirstOrDefault(); // //look for modified column name in mapping and replace with new column data // if (existingRecord != null) { // var templateDetailsEntity = _dbContext.TemplateDetails.Where(t=>t.TemplateDetailId== x.TemplateDetailId).FirstOrDefault(); // if( existingRecord.ColumnName != x.ColumnName || existingRecord.MandatoryFlag != x.MandatoryFlag) // { // templateDetailsEntity.ColumnName = x.ColumnName; // templateDetailsEntity.MandatoryFlag = x.MandatoryFlag; // templateDetailsEntity.UpdatedBy = x.UpdatedBy; // templateDetailsEntity.UpdatedDate = x.UpdatedDate; // } // templateDetailsEntity.Order = x.Order; // _dbContext.TemplateDetails.Update(templateDetailsEntity); // } // else //Add record if not exists // { // TemplateDetails tempNewRecord = Extensions.Clone(x); // tempNewRecord.TemplateDetailId = 0; // tempNewRecord.CreatedDate = DateTime.Now; // tempNewRecord.CreatedBy = x.UpdatedBy; // tempNewRecord.UpdatedBy = null; // tempNewRecord.UpdatedDate = null; // _dbContext.Add(tempNewRecord); // } //}); ////check for status and update mapping status accordingly //outgestion.OutgestionStatusUpdateForTemplateId(_dbContext, template.TemplateId, template.Status); #endregion _dbContext.SaveChanges(); } } catch { throw; } }