Ejemplo n.º 1
0
        public async Task <IActionResult> CreateCustomerNotes(Guid id, [FromBody] NewNoteRequest model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var customer = await _context.Customers.FindAsync(id);

            if (customer is null)
            {
                return(NotFound());
            }
            var note = customer.AddNote(model.Text, model.CreatedBy);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("note", new { Id = id, noteId = note.Id }, note));
        }