Beispiel #1
0
        public void Update(int id, NoteCreateUpdateDto note)
        {
            var noteToUpdate = todoListContext.Notes.FirstOrDefault(noteEntity => noteEntity.Id == id);

            mapper.Map(note, noteToUpdate);
            todoListContext.SaveChanges();
        }
Beispiel #2
0
        public void Add(NoteCreateUpdateDto note)
        {
            Note result = mapper.Map <Note>(note);

            todoListContext.Notes.Add(new Note()
            {
                Text = note.Text, CategoryId = 1
            });
            todoListContext.SaveChanges();
        }
Beispiel #3
0
        public IActionResult Update(int id, NoteCreateUpdateDto note)
        {
            if (!noteValidator.ValidateExistence(id) || !noteValidator.ValidateAdd(note))
            {
                return(new BadRequestResult());
            }

            noteRepository.Update(id, note);

            return(new NoContentResult());
        }
Beispiel #4
0
        public IActionResult Add(NoteCreateUpdateDto note)
        {
            if (!noteValidator.ValidateAdd(note))
            {
                return(new BadRequestResult());
            }

            noteRepository.Add(note);

            return(new NoContentResult());
        }
Beispiel #5
0
 public bool ValidateAdd(NoteCreateUpdateDto note)
 {
     return(note.Text != null && note.CategoryId > 0 && categoryValidator.ValidateExistence(note.CategoryId));
 }
Beispiel #6
0
 public IActionResult Put(int id, [FromBody] NoteCreateUpdateDto note)
 {
     return(_noteService.Update(id, note));
 }
Beispiel #7
0
 public IActionResult Post([FromBody] NoteCreateUpdateDto note)
 {
     return(_noteService.Add(note));
 }