public static SynonymGroupDomain ToDomain(this SynonymGroupRequest request) { return(new SynonymGroupDomain() { Name = request.Name, CreatedAt = request.CreatedAt }); }
public static SynonymGroup ToEntity(this SynonymGroupRequest request) { return(new SynonymGroup() { Name = request.Name, CreatedAt = request.CreatedAt }); }
public SynonymGroupResponse ExecuteCreate(string accessToken, SynonymGroupRequest requestParams) { var gatewayResponse = _synonymGroupsGateway.CreateSynonymGroup(requestParams.ToEntity()); return(gatewayResponse == null ? new SynonymGroupResponse() : gatewayResponse.ToResponse()); }
private async Task LoopSpreadsheetAndUpdateDatabaseWithChanges(string accessToken, SynonymGroupResponseList synonymGroupsResponseList, IDictionary <string, string[]> synonymGroups) { //Loop spreadsheet list and update changes if required DateTime today = DateTime.Now; if (synonymGroupsResponseList == null) { synonymGroupsResponseList = new SynonymGroupResponseList() { SynonymGroups = new List <SynonymGroupResponse>() } } ; foreach (var sg in synonymGroups) { if (sg.Value.Length > 0) { int groupId = 0; var synonymGroup = synonymGroupsResponseList.SynonymGroups.Find(s => s.Name.ToLower() == sg.Key.ToLower()); if (synonymGroup == null) //Add { SynonymGroupRequest synonymGroupRequest = new SynonymGroupRequest() { Name = sg.Key, CreatedAt = today }; var response = ExecuteCreate(accessToken, synonymGroupRequest); groupId = response.Id; } else { groupId = synonymGroup.Id; } SynonymWordSearchRequest requestWordParams = new SynonymWordSearchRequest() { Direction = "asc", GroupId = groupId, Sort = "word" }; SynonymWordResponseList synonymWordResponseList = ExecuteGetWord(requestWordParams); if (synonymWordResponseList == null) { synonymWordResponseList = new SynonymWordResponseList() { SynonymWords = new List <SynonymWordResponse>() } } ; List <SynonymWord> words = new List <SynonymWord>(); foreach (string word in sg.Value) { if (!string.IsNullOrEmpty(word)) { var synonymWord = synonymWordResponseList.SynonymWords.Find(w => w.Word.ToLower() == word.ToLower()); if (synonymWord == null)//Add { SynonymWordRequest synonymWordRequest = new SynonymWordRequest() { Word = word, CreatedAt = today, GroupId = groupId }; var response = ExecuteCreateWord(accessToken, synonymWordRequest); synonymWordResponseList = ExecuteGetWord(requestWordParams);//Refresh list } } } } } }