Ejemplo n.º 1
0
        public void Create(string name, string fontFamily, int fontSize)
        {
            name = name.Trim();

            if (name.Length == 0)
            {
                throw new ValidationException("Name is required.");
            }

            if (_nameForbiddenChars.Any(x => name.Contains(x)))
            {
                throw new ValidationException("Name cannot contain any of the following characters: /, \\, <, >, :, \", |, ?, *");
            }

            if (_notesRepository.Exists(name))
            {
                throw new ValidationException("A note with the same name already exists.");
            }

            _notesRepository.Create(name);

            var note = new Note(name, string.Empty, DateTime.Now, new NoteMetadata(fontFamily, fontSize));

            _notesMetadataService.Add(note.Name, note.Metadata);
            _notesMetadataService.Save();

            Created.Invoke(this, new CreatedNoteEventArgs
            {
                CreatedNote = note
            });
        }
Ejemplo n.º 2
0
        public CreateNoteResponse Create([FromBody] NoteRequest note)
        {
            var newNote   = new Note(note.Title, note.Contents);
            var newNoteId = _notesRepository.Create(newNote);

            return(new CreateNoteResponse(newNoteId));
        }
Ejemplo n.º 3
0
        public async Task <Result <Note> > Handle(CreateNoteRequest request, CancellationToken cancellationToken = default)
        {
            var invoice = await _invoicesRepository.Get(request.InvoiceId);

            var note = invoice.AddNote(request.Text, request.User.GetIdentity());

            await _notesRepository.Create(note);

            return(note);
        }
Ejemplo n.º 4
0
        public void Create(NoteForm noteForm)
        {
            var now = DateTime.UtcNow;

            var note = new Note
            {
                CreationDate   = now,
                ExpirationDate = noteForm.MinutesToExpire == 0 ? (DateTime?)null : now.AddMinutes(noteForm.MinutesToExpire),
                Text           = noteForm.Text,
                Title          = noteForm.Title
            };

            _notesRepository.Create(note);
        }
Ejemplo n.º 5
0
        public NoteResponse Create(NoteRequest model, AccessTokenData accessTokenData)
        {
            ValidateNote(model);

            var addedNote = _notesRepository.Create(new NoteEntity()
            {
                Name        = model.Name,
                CreatedTime = DateTime.Now,
                UpdateTime  = DateTime.Now,
                Text        = model.Text,
                UserKey     = accessTokenData.UserKey
            });

            return(ToNoteResponse(addedNote));
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> CreateForTopic(Guid topicId, NoteForCreation noteForCreation)
        {
            var entity = new Note
            {
                Title       = noteForCreation.Title,
                Description = noteForCreation.Description,
                CreatedById = noteForCreation.CreatedById,
                TopicId     = topicId
            };

            await repository.Create(entity);

            await repository.Save();

            return(Ok());
        }
Ejemplo n.º 7
0
        public async Task <String> PostAsync([FromBody] string value)
        {
            string NewInsertionID = "0";

            try
            {
                Notes newNote = JsonConvert.DeserializeObject <Notes>(value);
                NewInsertionID = await _NotesRepo.Create(newNote);
            }
            catch (Exception ex)
            {
                var logger = _loggerFactory.CreateLogger("internal_error_log");
                logger.LogInformation("Problem happened in making new vendor with message" + ex.Message);
            }
            return(NewInsertionID);
        }
Ejemplo n.º 8
0
        public virtual ActionResult Create(NoteViewModel model)
        {
            if (ModelState.IsValid)
            {
                var note = new Note()
                {
                    Date  = model.Date,
                    Text  = model.Text,
                    Title = model.Title
                };

                _notesRepository.Create(note);

                return(RedirectToAction(MVC.Admin.Notes.List()));
            }

            return(View(model));
        }
Ejemplo n.º 9
0
        public async Task <ResultDto <Guid, NotesCreateStatus> > Create(NotesCreateRequest request)
        {
            var model = _mapper.Map <NotesCreateRequest, Notes>(request);

            model.CreateDateTime = DateTime.UtcNow;
            try
            {
                var result = await _repository.Create(model);

                return(result);
            }
            catch (DbUpdateConcurrencyException)
            {
                return(new ResultDto <Guid, NotesCreateStatus>(NotesCreateStatus.InternalServerError));
            }
            catch (Exception ex)
            {
                return(new ResultDto <Guid, NotesCreateStatus>(NotesCreateStatus.InternalServerError));
            }
        }
Ejemplo n.º 10
0
        public int Create(Note note)
        {
            note.Validate();

            return(customerRepository.Create(note));
        }