public void Insert(Language entity) { //save language _context.Languages.Add(entity); Save(); //save mappings for new lang var contents = _contentRepository.GetAll(); foreach (var content in contents) { var contentMapping = new ContentMapping { LanguageId = entity.Id, ContentId = content.Id }; _contentMappingRepository.Insert(contentMapping); } Save(); }
public ContentMapping DefaultContent(string sfmKEY) { string marker, desc, className="", dest="", ws, langDesc; int count, order; marker = sfmKEY; desc = className = dest = ws = langDesc = ContentMapping.Unknown(); desc = ""; // leave empty now className = ""; dest = ""; // AutoDescriptionText(); // search through the langs and find the autolang to use GetLangInfoForAutoFields(out langDesc, out ws); Sfm2Xml.ClsFieldDescription startMapFieldData = this.GetFieldDescription(sfmKEY); count = m_DataInfo.GetSFMWithDataCount(sfmKEY); order = m_DataInfo.GetSFMOrder(sfmKEY); ContentMapping uiData = new ContentMapping(marker, desc, className, dest, ws, langDesc, count, order, null, false); return uiData; }
private bool MergeData(bool mergeWithExistingDataInUI) { string marker, desc, className="", dest="", ws, langDesc, fwID; string userLabel, customClassName, fieldType; // custom values int count, order; bool result = false; // return true if the we're updating from a currently loaded file and it's different bool isCustom = false; if (!mergeWithExistingDataInUI) m_htMarkerData = new Hashtable(); else { System.Collections.Generic.List<object> keysToDelete = new System.Collections.Generic.List<object>(); // remove ones from memory that no longer exist in the data foreach (DictionaryEntry de in m_htMarkerData) { if (!m_DataInfo.ContainsSfm(de.Key as string)) keysToDelete.Add(de.Key); } // now if we found any to delete - do it. for (int index = 0; index < keysToDelete.Count; index++) { m_htMarkerData.Remove(keysToDelete[index]); } result = keysToDelete.Count > 0; // if we've deleted something than we know the UI data has to be different } foreach( string sfmKEY in m_DataInfo.SfmInfo) { // LT-1926 Ignore all markers that start with underscore (shoebox markers) if (sfmKEY.StartsWith("_")) continue; // if the marker contains invalid characters for the xml element, ignore it??? marker = sfmKEY; count = m_DataInfo.GetSFMWithDataCount(sfmKEY); order = m_DataInfo.GetSFMOrder(sfmKEY); fwID = ""; isCustom = false; if (m_htMarkerData.ContainsKey(sfmKEY)) { // just update the count and order as the other fields could have been editied in the UI ContentMapping uiData = m_htMarkerData[sfmKEY] as ContentMapping; uiData.Count = count; uiData.Order = order; } else { if (mergeWithExistingDataInUI) result = true; // we are adding a new one, so the UI data will be different // get the field description info from the map file for this marker Sfm2Xml.ClsFieldDescription mapField = this.FieldMarkerHashTable[marker] as Sfm2Xml.ClsFieldDescription; if (mapField is Sfm2Xml.ClsCustomFieldDescription) { isCustom = true; userLabel = (mapField as Sfm2Xml.ClsCustomFieldDescription).Name; customClassName = (mapField as Sfm2Xml.ClsCustomFieldDescription).ClassNameUI; fieldType = (mapField as Sfm2Xml.ClsCustomFieldDescription).Type; // first make sure if it's a custom field, that the field exists in the database if (!IsValidCustomField(mapField)) mapField = null; // treat like not existint (not in DB at this point) } if (mapField == null) { // case where the marker in the data isn't in the map file - Now an AutoImport field by default desc = className = dest = ws = langDesc = ContentMapping.Unknown(); desc = ""; // leave empty now // desc = AutoDescriptionText(); className = ""; dest = ""; // AutoDescriptionText(); // search through the langs and find the autolang to use GetLangInfoForAutoFields(out langDesc, out ws); } else { desc = mapField.Name; if (mapField.IsAutoImportField) { // desc = AutoDescriptionText(); // className = dest = ""; desc = ""; dest = ""; // AutoDescriptionText(); className = ""; } else if (mapField.MeaningApp == "fw.sil.org") { // use the meaning id and get the lex import field with this name if (mapField.MeaningID.Length > 0) { fwID = mapField.MeaningID; if (mapField is Sfm2Xml.ClsCustomFieldDescription) { Sfm2Xml.ClsCustomFieldDescription custom = mapField as Sfm2Xml.ClsCustomFieldDescription; className = custom.ClassNameUI; dest = custom.Name;// +" (Custom " + className + ")"; // MeaningID; // custom.Name; } else { // dest = m_LexFields.GetUIDestForName(mapField.MeaningID); if (!m_LexFields.GetDestinationForName(mapField.MeaningID, out className, out dest)) className = dest = ContentMapping.Unknown(); } } else { className = ContentMapping.Unknown(); dest = ContentMapping.Unknown(); // "Unknown " + mapField.MeaningApp + " ID<" + mapField.MeaningID + ">"; } } else { className = dest = ContentMapping.Unknown(); } // now get the writing system: // - default to "Unknown" if not found // - see if there is a map value // - see if the map value key's into the UI languages ws = langDesc = ContentMapping.Unknown(); string mapWS = mapField.Language; if (m_htUILangInfo.ContainsKey(mapWS)) { ws = (m_htUILangInfo[mapWS] as Sfm2Xml.LanguageInfoUI).FwName; langDesc = mapWS; } } Sfm2Xml.ClsFieldDescription startMapFieldData = this.GetFieldDescription(marker); if (startMapFieldData is Sfm2Xml.ClsCustomFieldDescription) { Sfm2Xml.ILexImportCustomField licf = m_LexFields.GetCustomField(startMapFieldData as Sfm2Xml.ClsCustomFieldDescription); if (licf == null) startMapFieldData = null; else { startMapFieldData = licf.ClsFieldDescriptionWith(startMapFieldData); licf.UIClass = (startMapFieldData as Sfm2Xml.ClsCustomFieldDescription).ClassNameUI; } isCustom = true; } ContentMapping uiData = new ContentMapping(marker, desc, className, dest, ws, langDesc, count, order, startMapFieldData, isCustom); uiData.FwId = fwID; uiData.AddLexImportField(m_LexFields.GetField(className, fwID)); m_htMarkerData.Add(marker, uiData); } } // Now for each HierarchyEntry, set the individual marker begin fields Hashtable htHierarchy = HierarchyHashTable; foreach(DictionaryEntry dictEentry in htHierarchy) { Sfm2Xml.ClsHierarchyEntry hierarchy = dictEentry.Value as Sfm2Xml.ClsHierarchyEntry; foreach (string beginSfm in hierarchy.BeginFields) { if (m_htMarkerData.ContainsKey(beginSfm)) { ContentMapping uiData = m_htMarkerData[beginSfm] as ContentMapping; uiData.IsBeginMarker = true; } } } return result; }
public bool ReplaceContentMappingItem(ContentMapping contentMapping) { string sfmKey = contentMapping.Marker; if (m_htMarkerData.ContainsKey(sfmKey)) { m_htMarkerData.Remove(sfmKey); m_htMarkerData.Add(sfmKey, contentMapping); return true; } return false; }
public static ContentMapping ToEntity(this ContentMappingModel model, ContentMapping destination, IMapper _mapper) { return(_mapper.Map(model, destination)); }
public static ContentMappingModel ToModel(this ContentMapping entity, IMapper _mapper) { return(_mapper.Map <ContentMapping, ContentMappingModel>(entity)); }
public void Delete(ContentMapping entity) { var contentMapping = _context.ContentMappings.Where(c => c.Id == entity.Id); Delete(entity); }
public void Update(ContentMapping entity) { Save(); }
public int InsertAndGetId(ContentMapping entity) { _context.ContentMappings.Add(entity); Save(); return(entity.Id); }
public void Insert(ContentMapping entity) { _context.ContentMappings.Add(entity); }