public void AddNote(NoteDTOM noteModel) { NoteHelper.ValidateNoteEmptyString(noteModel); var note = NoteMapper.NoteModelToNote(noteModel); _noteRepo.Insert(note); }
public NoteDTOM GetNoteById(int id) { var note = _noteRepo.GetById(id); NoteHelper.ValidateNoteById(note.Id); return(NoteMapper.NoteToNoteModel(note)); }
private ActionResult RenderDayView(DateTime?from, DateTime?to, List <NoteTypeModel> noteTypes) { DateTime selectedDate; var selectedDateCookie = GetCookie(_selectedDateCookie); if (selectedDateCookie == null) { selectedDate = DateTime.Now.Date; SetCookie(_selectedDateCookie, selectedDate.ToString("o")); } else { selectedDate = DateTime.Parse(selectedDateCookie).Date; } List <Note> notes; if (from.HasValue && to.HasValue) { if (from.Value <= selectedDate && selectedDate <= to.Value) { notes = _noteService.GetAll(selectedDate, selectedDate, noteTypes); } else { notes = new List <Note>(); } } else { if (!from.HasValue && !to.HasValue) { notes = _noteService.GetAll(selectedDate, selectedDate, noteTypes); } else if (from.HasValue && from.Value <= selectedDate) { notes = _noteService.GetAll(selectedDate, selectedDate, noteTypes); } else if (to.HasValue && to.Value >= selectedDate) { notes = _noteService.GetAll(selectedDate, selectedDate, noteTypes); } else { notes = new List <Note>(); } } notes = notes.OrderBy(note => note.DateTime).ToList(); var noteModels = NoteMapper.Map(notes); var list = new DayViewModeModel() { SelectedDate = selectedDate, Notes = noteModels, }; return(PartialView("Diary/ViewModes/Day", list)); }
public void should_play_c_when_swing_at_85() { var playingDevice = new Mock <IPlayingDevice>(); var mapper = new NoteMapper(90, playingDevice.Object); mapper.Map(0, 85, MovingDir.Left); playingDevice.Verify(c => c.PlayNote(Midi.Pitch.C0)); }
public void should_play_nothing_above_85() { var playingDevice = new Mock <IPlayingDevice>(); var mapper = new NoteMapper(90, playingDevice.Object); mapper.Map(0, 90, MovingDir.Left); playingDevice.Verify(c => c.PlayNote(Midi.Pitch.C0), Times.Never); }
public ActionResult AddNote(NoteViewModel viewModel) { if (ModelState.IsValid) { Service.Add(NoteMapper.Map(viewModel)); } return(GetUserNotes()); }
public NoteModel GetNoteById(int id) { var note = _noteRepo.GetById(id); if (note == null) { throw new NoteException(id, 0, "Invalid note id!"); } return(NoteMapper.NoteToNoteModel(note)); }
public void SaveNotes(IEnumerable <DomainNote> notes) { var data = new NotebookData { Notes = NoteMapper.Convert(notes.ToList()), TimeStamp = timeProvider.Now }; string json = JsonConvert.SerializeObject(data); // for now, possible exceptions will be handled on the application-level File.WriteAllText(filePath, json); }
public IList <DomainNote> LoadNotes() { if (File.Exists(filePath)) { string json = File.ReadAllText(filePath); var notes = JsonConvert.DeserializeObject <NotebookData>(json).Notes; return(NoteMapper.Convert(notes)); } return(new List <DomainNote>()); }
public void UpdateNote(NoteDTOM noteModel) { var noteCheck = _noteRepo.GetById(noteModel.Id); NoteHelper.ValidateNoteById(noteCheck.Id); NoteHelper.ValidateNoteEmptyString(noteModel); var note = NoteMapper.NoteModelToNote(noteModel); _noteRepo.Update(note); }
private ActionResult RenderListView(DateTime?from, DateTime?to, List <NoteTypeModel> noteTypes) { var notes = _noteService.GetAll(from, to, noteTypes); notes = notes.OrderBy(note => note.DateTime).ToList(); var noteModels = NoteMapper.Map(notes); var list = new ListViewModeModel() { Notes = noteModels }; return(PartialView("Diary/ViewModes/List", list)); }
public IEnumerable <NoteDTO> GetNotesAsDTOs() { try { var aList = GetNotes(); return(NoteMapper.MapNoteToNoteDTOs(aList));; } catch (Exception ex) { //UnitOfWork.WriteErrorLog(ex); } return(null); }
///////////////INTERFACE METHOD////////////////////// public NoteDTO CreateNoteDTO(int userId, int postId, string body) { try { var a = CreateNote(userId, postId, body); return(NoteMapper.MapNoteToNoteDTO(a)); } catch (Exception ex) { // UnitOfWork.WriteErrorLog(ex); } return(null); }
public void AddNote(NoteModel noteModel) { if (string.IsNullOrEmpty(noteModel.Text)) { throw new NoteException(null, noteModel.UserId, "Text field is required!"); } if (noteModel.Color.Count() < 3) { throw new NoteException(null, noteModel.UserId, "Color field can not have less than 3 characters!"); } var note = NoteMapper.NoteModelToNote(noteModel); _noteRepo.Insert(note); }
public void UpdateNote(NoteModel noteModel) { var noteCheck = _noteRepo.GetById(noteModel.Id); if (noteCheck == null) { throw new NoteException(noteModel.Id, 0, "No such note to be updated!"); } if (string.IsNullOrEmpty(noteModel.Text)) { throw new NoteException(null, noteModel.UserId, "Text field is required!"); } if (noteModel.Color.Count() < 3) { throw new NoteException(null, noteModel.UserId, "Color field can not have less than 3 characters!"); } var note = NoteMapper.NoteModelToNote(noteModel); _noteRepo.Update(note); }
public NoteDTO GetNoteAsDTO(int userId, int postId) { var a = GetNote(userId, postId); return(NoteMapper.MapNoteToNoteDTO(a)); }
public List <NoteModel> GetAllNotes() { var notes = _noteRepo.GetAll().ToList(); return(NoteMapper.NotesToNotesModels(notes)); }