protected virtual void SetupFilter(ICriteria crit, NotesFilter filter) { if (filter != null) { if (!string.IsNullOrEmpty(filter.Name)) { crit.Add(Restrictions.Like("Name", filter.Name, MatchMode.Anywhere)); } if (filter.CreationDate != null) { if (filter.CreationDate.From.HasValue) { crit.Add(Restrictions.Ge("Created", filter.CreationDate.From.Value)); } if (filter.CreationDate.To.HasValue) { crit.Add(Restrictions.Le("Created", filter.CreationDate.To.Value)); } } if (filter.ChangingDate != null) { if (filter.ChangingDate.From.HasValue) { crit.Add(Restrictions.Ge("Changed", filter.CreationDate.From.Value)); } if (filter.CreationDate.To.HasValue) { crit.Add(Restrictions.Le("Changed", filter.CreationDate.To.Value)); } } } }
// GET: Notes public ActionResult ShowNotes(NotesFilter filter, FetchOptions options) { var model = new NotesListViewModel { Notes = notesMethods.GetUsersNotes(CurrentUser, filter, options) }; return(View(model)); }
public List <Notes> getNotesByFilter(NotesFilter filter) { return(_context.Notes .AsNoTracking() .Include(x => x.Event) .Include(x => x.Rating) .Include(x => x.Attendee) .Where(n => n.CompanyId == filter.CompanyId) .Where(matchesFilter(filter)) .ToList()); }
public IList <Note> GetUsersNotes(User user, NotesFilter filter = null, FetchOptions options = null) { var crit = session.CreateCriteria <Note>(); SetupFilter(crit, filter); crit.Add(Restrictions.Eq("Author.Id", user.Id)); if (options != null) { SetFetchOptions(crit, options); } return(crit.List <Note>()); }
/// <summary> /// The program is to be invoked with one argument, the input file. /// </summary> /// <param name="args">command line arguments</param> /// <returns>0 in case of no errors</returns> public static int Main(string[] args) { if (args.Length != 1) { Console.WriteLine("{0}Usage: getAllElementsWithNotes filename{0}{0}", Environment.NewLine); return(1); } string filename = args[0]; // read the document long start = DateTime.Now.Ticks; SBMLDocument document = libsbml.readSBMLFromFile(filename); long stop = DateTime.Now.Ticks; Console.WriteLine(); Console.WriteLine(" filename: {0}", filename); Console.WriteLine(" read time (ms): {0}", TimeSpan.FromTicks(stop - start).TotalMilliseconds); // stop in case of serious errors long errors = document.getNumErrors(libsbml.LIBSBML_SEV_ERROR); if (errors > 0) { Console.WriteLine(" error(s): {0}", errors); document.printErrors(); return((int)errors); } // create the filter we want to use var filter = new NotesFilter(); // get a list of all elements with notes start = DateTime.Now.Ticks; Console.WriteLine(" searching ......:"); SBaseList allElements = document.getListOfAllElements(filter); stop = DateTime.Now.Ticks; Console.WriteLine(" search time (ms): {0}", TimeSpan.FromTicks(stop - start).TotalMilliseconds); Console.WriteLine(); Console.WriteLine(" elements with notes: {0}", allElements.getSize()); Console.WriteLine(); // if we got here all went well ... return(0); }
/// <summary> /// The program is to be invoked with one argument, the input file. /// </summary> /// <param name="args">command line arguments</param> /// <returns>0 in case of no errors</returns> public static int Main(string[] args) { if (args.Length != 1) { Console.WriteLine("{0}Usage: getAllElementsWithNotes filename{0}{0}", Environment.NewLine); return 1; } string filename = args[0]; // read the document long start = DateTime.Now.Ticks; SBMLDocument document = libsbml.readSBMLFromFile(filename); long stop = DateTime.Now.Ticks; Console.WriteLine(); Console.WriteLine(" filename: {0}", filename); Console.WriteLine(" read time (ms): {0}", TimeSpan.FromTicks(stop - start).TotalMilliseconds); // stop in case of serious errors long errors = document.getNumErrors(libsbml.LIBSBML_SEV_ERROR); if (errors > 0) { Console.WriteLine(" error(s): {0}", errors); document.printErrors(); return (int)errors; } // create the filter we want to use var filter = new NotesFilter(); // get a list of all elements with notes start = DateTime.Now.Ticks; Console.WriteLine(" searching ......:"); SBaseList allElements = document.getListOfAllElements(filter); stop = DateTime.Now.Ticks; Console.WriteLine(" search time (ms): {0}", TimeSpan.FromTicks(stop - start).TotalMilliseconds); Console.WriteLine(); Console.WriteLine(" elements with notes: {0}", allElements.getSize()); Console.WriteLine(); // if we got here all went well ... return 0; }
public List <NoteModel> getNotesByFilter(NotesFilter filter) { List <Notes> allNotes = _NotesRepository.getNotesByFilter(filter); List <NoteModel> groupedNotes = new List <NoteModel>(); foreach (Notes note in allNotes) { if (groupedNotes.Count() == 0) { NoteModel newNote = new NoteModel(); newNote.notes = new List <Notes>(); newNote.notes.Add(note); newNote.averageRating = note.Rating.Value; groupedNotes.Add(newNote); } else { if (groupedNotes.Any(x => x.notes.Any(n => n.AttendeeId == note.AttendeeId))) { NoteModel newNote = groupedNotes.Where(x => x.notes.Any(n => n.AttendeeId == note.AttendeeId)).FirstOrDefault(); newNote.notes.Add(note); newNote.averageRating += note.Rating.Value; } else { NoteModel newNote = new NoteModel(); newNote.notes = new List <Notes>(); newNote.notes.Add(note); newNote.averageRating = note.Rating.Value; groupedNotes.Add(newNote); } } } foreach (NoteModel set in groupedNotes) { set.averageRating = set.averageRating / set.notes.Count(); set.notes = set.notes.OrderByDescending(n => n.Date).ToList(); } return(groupedNotes); }
public IActionResult Filter(DateTime from, DateTime to, string category) { NotesFilter.updateFilter(from, to, category); Notebook.updateDisplay(-1); return(View("Index")); }
public List <NoteModel> GetNotesByFilter([FromBody] NotesFilter filter) { return(_notesService.getNotesByFilter(filter)); }
private System.Linq.Expressions.Expression <System.Func <Notes, bool> > matchesFilter(NotesFilter filter) { if (filter == null) { return(notes => false); } return(notes => (filter.Start == null || notes.Event.StartTime >= filter.Start) && (filter.End == null || notes.Event.EndTime <= filter.End) && (filter.AttendeeName == null || (notes.Attendee.FirstName + " " + notes.Attendee.LastName).Contains(filter.AttendeeName)) && (filter.Degree == null || (notes.Attendee.Degree.Contains(filter.Degree))) && (filter.Rating == null || (notes.RatingId == filter.Rating.RatingId)) && (filter.University == null || (notes.Attendee.University == filter.University))); }