public IActionResult CreateNote([FromBody] NoteForCreation noteForCreation) { if (noteForCreation == null) { return(BadRequest("Posted data is invalid")); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var note = Mapper.Map <Note>(noteForCreation); _noteRepository.Add(note); if (!_noteRepository.Save()) { return(StatusCode(500, "Failed to handle your request. Unknown errors.")); } var createNoteModel = Mapper.Map <NoteModel>(note); return(CreatedAtRoute("GetNote", new { id = createNoteModel.Id }, createNoteModel)); }
public ActionResult CreateNote(NoteForCreation noteDto) { var note = _mapper.Map <Note>(noteDto); _noteService.CreateNote(note); return(CreatedAtRoute( nameof(GetNote), new { userEmail = note.UserEmail, noteId = note.Id }, CreateNoteDto(note))); }
public ActionResult CreateNotes(NoteForCreation noteDto) { var note = _mapper.Map <Notes>(noteDto); _dataService.Create(note); return(CreatedAtRoute( nameof(GetNote), new { noteId = note.Id }, CreateNoteDto(note))); }
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()); }