[HttpGet("[action]")] // GET api/notes/getsearch public async Task <IActionResult> GetSearch([FromQuery] NotesSearchParam notesSearchParam) // NotesSearchDto notesSearch { try { // TODO: tmp, refactor var notesSearch = new NotesSearchDto(); notesSearch.TextSearch = notesSearchParam.TextSearch; if (notesSearchParam.PageNumber > 0) { notesSearch.PageIdentifier.PageNumber = notesSearchParam.PageNumber; } notesSearch.PageIdentifier.PageSize = notesSearchParam.PageSize; // ..... var kresApi = await _service.Notes.GetSearch(notesSearch); if (kresApi.IsValid) { return(Ok(kresApi)); } else { return(BadRequest(kresApi)); } } catch (Exception ex) { var kresApi = new Result <List <NoteInfoDto> >(); kresApi.AddErrorMessage("Generic error: " + ex.Message); return(BadRequest(kresApi)); } }
public async Task <bool> LoadVarsFromRepository(string varIdentifier, string repositoryAlias) { ServiceRef serviceRef; if (string.IsNullOrEmpty(repositoryAlias)) { serviceRef = _store.GetFirstServiceRef(); } else { serviceRef = _store.GetServiceRef(repositoryAlias); } if (serviceRef == null || varIdentifier == null) { throw new Exception("Invalid parameter."); } NotesSearchDto search = new NotesSearchDto { TextSearch = $"{varIdentifier} " }; var note = (await serviceRef.Service.Notes.GetSearch(search)).Entity.FirstOrDefault(); string content = note?.Description; if (content != null) { //tagVars = note.Description; dictionaryVars = new Dictionary <string, string>(); string[] lines = note.Description?.Split( new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None ); foreach (string s in lines) { var splitVar = s.Split('='); if (splitVar.Length == 2) { splitVar[0] = splitVar[0].Trim(); splitVar[1] = splitVar[1].Trim(); if (dictionaryVars.ContainsKey(splitVar[0])) { dictionaryVars[splitVar[0]] = splitVar[1]; } else { dictionaryVars.Add(splitVar[0], splitVar[1]); } } } return(true); } else { return(false); } }
public async Task <Result <List <NoteInfoDto> > > GetSearch(NotesSearchDto notesSearch) { return(await _repository.Notes.GetSearch(notesSearch)); }