/// <summary> /// get the label which is on note. /// </summary> /// <param name="notesLabelModel">note label data model.</param> /// <returns>return the label data.</returns> public IList <LabelModel> GetNoteLabelById(NotesLabelModel notesLabelModel) { if (notesLabelModel.Equals(null)) { try { var result = this.repositoryManager.GetNoteLabelById(notesLabelModel); if (!result.Equals(null)) { return(result); } else { throw new Exception(); } } catch (Exception ex) { throw new Exception(ex.Message); } } else { throw new Exception(); } }
/// <summary> /// Adds label on notes. /// </summary> /// <param name="notesLabelModel">The NotesLabel model data.</param> /// <returns> return result.</returns> /// <exception cref="Exception"> /// throw exception. /// </exception> public async Task <int> AddNoteLabel(NotesLabelModel notesLabelModel) { try { ///check notes label model data is not null if (!notesLabelModel.Equals(null)) { ////repositoryManager layer method called var result = await this.repositoryManager.AddNoteLabel(notesLabelModel); if (result > 0) { return(result); } else { throw new Exception(); } } else { throw new Exception(); } } catch (Exception ex) { throw new Exception(ex.Message); } }
/// <summary> /// Gets the label by identifier. /// </summary> /// <param name="LabelId">The label identifier.</param> /// <returns>return result.</returns> public IList <LabelModel> GetNoteLabelById(NotesLabelModel notesLabelModel) { try { var list = new List <LabelModel>(); var GetData = from notelabel in this.authenticationContext.NotesLabel where notelabel.UserId.Equals(notesLabelModel.UserId) && notelabel.NoteId.Equals(notesLabelModel.NoteId) select notelabel; foreach (var data in GetData) { var result = from label in this.authenticationContext.Label where label.Id.Equals(data.LabelId) && (label.UserId.Equals(data.UserId)) select label; foreach (var label in result) { list.Add(label); } } return(list); } catch (Exception ex) { throw new Exception(ex.Message); } }
/// <summary> /// Adds the label. /// </summary> /// <param name="labelModel">The label model.</param> /// <returns>return result.</returns> /// <exception cref="Exception">throw exception.</exception> public Task <int> AddNoteLabel(NotesLabelModel notesLabelModel) { try { var labelData = from label in this.authenticationContext.Label where label.Id == notesLabelModel.LabelId select label; NotesLabelModel labelModel = new NotesLabelModel() { UserId = notesLabelModel.UserId, LabelId = notesLabelModel.LabelId, NoteId = notesLabelModel.NoteId, CreatedDate = notesLabelModel.CreatedDate, }; this.authenticationContext.Add(labelModel); var result = this.authenticationContext.SaveChangesAsync(); return(result); } catch (Exception ex) { throw new Exception(ex.Message); } }
public async Task <int> AddNoteLabel(NotesLabelModel notesLabelModel) { try { ////businessManager Layer method call. var result = await this.businessManager.AddNoteLabel(notesLabelModel); return(result); } catch (Exception ex) { throw new Exception(ex.Message); } }
public IActionResult GetNoteLabelById() { try { NotesLabelModel notesLabelModel = new NotesLabelModel(); IList <LabelModel> result = this.businessManager.GetNoteLabelById(notesLabelModel); if (!result.Equals(null)) { return(this.Ok(new { result })); } else { return(this.NotFound()); } } catch (Exception ex) { throw new Exception(ex.Message); } }