public IResult <INoteReturn> AddNote(string notebookKey, ICreateNoteParameters parameters) { if (notebookKey == null) { throw new ArgumentNullException("notebookKey"); } var keyResult = KeyParserHelper.ParseResult <INotebookKey>(notebookKey); if (!keyResult.Success) { return(keyResult.ConvertTo <INoteReturn>()); } var key = new NotebookKey(keyResult.ResultingObject); var createNoteResult = new CreateNoteCommand(_notebookUnitOfWork).Execute(key, _timeStamper.CurrentTimeStamp, parameters); if (!createNoteResult.Success) { return(createNoteResult.ConvertTo <INoteReturn>()); } _notebookUnitOfWork.Commit(); return(SyncParameters.Using(new SuccessResult <INoteReturn>(new[] { createNoteResult.ResultingObject }.Select(NoteProjectors.Select().Compile()).FirstOrDefault()), key)); }
public IResult <INoteReturn> AddNote(string notebookKey, ICreateNoteParameters note) { try { return(_notebookServiceProvider.AddNote(notebookKey, note)); } catch (Exception ex) { _exceptionLogger.LogException(ex); return(new FailureResult <INoteReturn>(null, ex.Message)); } }
internal IResult <Note> Execute(INotebookKey notebookKey, DateTime timestamp, ICreateNoteParameters parameters) { if (notebookKey == null) { throw new ArgumentNullException("notebookKey"); } if (timestamp == null) { throw new ArgumentNullException("timestamp"); } if (parameters == null) { throw new ArgumentNullException("parameters"); } var employeeResult = new GetEmployeeCommand(_notebookUnitOfWork).GetEmployee(parameters); if (!employeeResult.Success) { return(employeeResult.ConvertTo((Note)null)); } var notebookKeyFind = new NotebookKey(notebookKey); var notebook = _notebookUnitOfWork.NotebookRepository.FindByKey(notebookKeyFind); if (notebook == null) { return(new InvalidResult <Note>(null, string.Format(UserMessages.NotebookNotFound, notebookKeyFind))); } return(Execute(notebook, timestamp, employeeResult.ResultingObject, parameters.Text)); }