public IList <NotesModel> GetNotesById(string userId, NoteTypeEnum noteType) { try { ////check the user id and note type is not null ///noteType is for isNote=0, isTrash = 1, isArchive=2 if (!userId.Equals(null) && !noteType.Equals(null)) { ////BusinessLayer method call var result = this._businessManager.GetNotesById(userId, noteType); ////check if (!result.Equals(null)) { ////return the all notes. return(result); } else { ////throw the exception throw new Exception("The data was not fetched successfuly"); } } else { ////throw the exception throw new Exception("user id or note type are invalid"); } } catch (Exception ex) { throw new Exception(ex.Message); } }
/// <summary> /// Gets the type of the note. /// </summary> /// <param name="notesModel">The notes model.</param> /// <returns></returns> public IList <NotesModel> GetNoteType(NoteTypeEnum noteType) { try { IList <NotesModel> list = new List <NotesModel>(); if (noteType == NoteTypeEnum.IsNote) { var NoteData = from notes in this.context.Notes where (notes.noteType == NoteTypeEnum.IsNote) select notes; foreach (var data in NoteData) { list.Add(data); } } else if (noteType == NoteTypeEnum.IsArchive) { var NoteData = from notes in this.context.Notes where (notes.noteType == NoteTypeEnum.IsArchive) select notes; foreach (var data in NoteData) { list.Add(data); } } else if (noteType == NoteTypeEnum.IsTrash) { var NoteData = from notes in this.context.Notes where (notes.noteType == NoteTypeEnum.IsTrash) select notes; foreach (var data in NoteData) { list.Add(data); } } return(list); } catch (Exception ex) { throw new Exception(ex.Message); } }
public IActionResult GetNoteType(NoteTypeEnum NoteType) { try { ////BusinessLayer method call var result = this._businessManager.GetNoteType(NoteType); if (!result.Equals(null)) { return(this.Ok(new { result })); } else { throw new Exception(); } } catch (Exception ex) { throw new Exception(ex.Message); } }
/// <summary> /// Gets the type of the notes. /// </summary> /// <param name="NoteType">The notes model.</param> /// <returns>return result.</returns> public IList <NotesModel> GetNoteType(NoteTypeEnum NoteType) { try { if (!NoteType.Equals(null)) { ////repositoryManager Layer method call var result = this.repositoryManager.GetNoteType(NoteType); return(result); } else { throw new Exception(); } } catch (Exception ex) { throw new Exception(ex.Message); } }
/// <summary> /// Get the notes by user id and note type. /// </summary> /// <param name="userId">user id.</param> /// <param name="noteType">note type.</param> /// <returns>return the notes.</returns> public IList <NotesModel> GetNotesById(string userId, NoteTypeEnum noteType) { try { ///note type value isNote=0 var noteList = new List <NotesModel>(); var note = from notedata in this.context.Notes where notedata.UserId == userId select notedata; foreach (var data in note) { if (data.noteType == noteType) { noteList.Add(data); } } return(noteList); } catch (Exception ex) { throw new Exception(ex.Message); } }
public IActionResult GetNoteType(NoteTypeEnum NoteType) { try { _logger.LogInformation("Could break here :("); ////BusinessLayer method call var result = this._businessManager.GetNoteType(NoteType); if (!result.Equals(null)) { return(this.Ok(new { result })); } else { throw new Exception(); } } catch (Exception ex) { _logger.LogError(e, "It broke :("); throw new Exception(ex.Message); } }
/// <summary> /// get notes by user id and note type. /// </summary> /// <param name="userId">user id.</param> /// <param name="noteType">note type.</param> /// <returns> return result.</returns> public IList <NotesModel> GetNotesById(string userId, NoteTypeEnum noteType) { try { ////concate the userId and data string for unique key in redis cache. var cachekey = Data + userId; using (var redis = new RedisClient()) { ////clean the redis cache. redis.Remove(cachekey); if (redis.Get(cachekey) == null) { //// repositoryManager layer method called var noteData = this.repositoryManager.GetNotesById(userId, noteType); if (noteData != null) { redis.Set(cachekey, userId); } return(noteData); } else { IList <NotesModel> list = new List <NotesModel>(); var list1 = redis.Get(cachekey); ////list.Add(list1); return(list); } } } catch (Exception ex) { throw new Exception(ex.Message); } }