This commit is contained in:
2018-09-27 19:38:50 +00:00
parent 03b21d29b4
commit 3528d3f69c
4 changed files with 65 additions and 17 deletions

View File

@@ -394,18 +394,23 @@ namespace AyaNova.Biz
//ITERATE THROUGH THE KEYWORDS THAT DO *NOT* HAVE MATCHES IN THE SEARCHDICTIONARY AND ADD THEM TO THE SEARCH DICTIONARY, COLLECTING THEIR ID'S
bool NewWordsAdded = false;
var NewSearchDictionaryWordsList = new List<SearchDictionary>();
foreach (string KeyWord in KeyWordList)
{
if (!ExistingKeywordMatches.ContainsValue(KeyWord))
{
ct.SearchDictionary.Add(new SearchDictionary() { Word = KeyWord });
NewSearchDictionaryWordsList.Add(new SearchDictionary() { Word = KeyWord });
NewWordsAdded = true;
}
}
//Save the context in order to get the id's of the new words added
if (NewWordsAdded)
{
//adding in a range sped this up noticeably
ct.SearchDictionary.AddRange(NewSearchDictionaryWordsList);
ct.SaveChanges();
}
//-----
@@ -432,14 +437,18 @@ namespace AyaNova.Biz
}
//CREATE THE SEARCHKEY RECORDS FOR ALL THE KEYWORDS
var NewSearchKeyList = new List<SearchKey>();
foreach (MatchingDictionaryEntry E in MatchingKeywordIdList)
{
ct.SearchKey.Add(new SearchKey() { WordId = E.DictionaryId, InName = E.InName, ObjectId = objectID, ObjectType = objectType });
NewSearchKeyList.Add(new SearchKey() { WordId = E.DictionaryId, InName = E.InName, ObjectId = objectID, ObjectType = objectType });
//ct.SearchKey.Add(new SearchKey() { WordId = E.DictionaryId, InName = E.InName, ObjectId = objectID, ObjectType = objectType });
}
ct.SearchKey.AddRange(NewSearchKeyList);
ct.SaveChanges();
//---------------------------------
ct.SaveChanges();
}//eoc

View File

@@ -95,7 +95,7 @@ namespace AyaNova.Biz
////////////////////////////////////////////////////////////////////////////////////////////////
//CREATE
internal User Create(User inObj)
internal User Create(AyContext TempContext, User inObj)
{
//This is a new user so it will have been posted with a password in plaintext which needs to be salted and hashed
inObj.Salt = Hasher.GenerateSalt();
@@ -113,18 +113,18 @@ namespace AyaNova.Biz
if (outObj.UserOptions == null)
outObj.UserOptions = new UserOptions(UserId);
ct.User.Add(outObj);
TempContext.User.Add(outObj);
//save to get Id
ct.SaveChanges();
TempContext.SaveChanges();
//Handle child and associated items
//Log event
EventLogProcessor.AddEntryToContextNoSave(new Event(UserId, outObj.Id, BizType, AyaEvent.Created), ct);
EventLogProcessor.AddEntryToContextNoSave(new Event(UserId, outObj.Id, BizType, AyaEvent.Created), TempContext);
//ct.SaveChanges();
//SEARCH INDEXING
Search.ProcessNewObjectKeywords(ct, UserLocaleId, outObj.Id, BizType, outObj.Name, outObj.EmployeeNumber, outObj.Notes, outObj.Name);
Search.ProcessNewObjectKeywords(TempContext, UserLocaleId, outObj.Id, BizType, outObj.Name, outObj.EmployeeNumber, outObj.Notes, outObj.Name);
return outObj;

View File

@@ -73,6 +73,33 @@ namespace AyaNova.Biz
}
}
////////////////////////////////////////////////////////////////////////////////////////////////
//CREATE
internal Widget Create(AyContext TempContext, Widget inObj)
{
Validate(inObj, true);
if (HasErrors)
return null;
else
{
//do stuff with widget
Widget outObj = inObj;
outObj.OwnerId = UserId;
TempContext.Widget.Add(outObj);
TempContext.SaveChanges();
//Handle child and associated items:
//EVENT LOG
EventLogProcessor.AddEntryToContextNoSave(new Event(UserId, outObj.Id, BizType, AyaEvent.Created), TempContext);
//SEARCH INDEXING
Search.ProcessNewObjectKeywords(TempContext, UserLocaleId, outObj.Id, BizType, outObj.Name, outObj.Notes, outObj.Name);
return outObj;
}
}
////////////////////////////////////////////////////////////////////////////////////////////////
/// GET