예제 #1
0
        public async Task <IActionResult> Post(ContactInput model)
        {
            _logger.LogDebug($"Creating a new contact with Email \"{model.Email}\"");

            var contact = new Contact();

            model.MapToContact(contact);

            await _contactRepository.Create(contact);

            return(CreatedAtAction(nameof(GetById), "contact", new { id = contact.Id }, contact));
        }
예제 #2
0
        public async Task <IActionResult> Put(int id, ContactInput model)
        {
            _logger.LogDebug($"Updating a contact with id {id}");

            var contact = await _contactRepository.GetById(id);

            if (contact == null)
            {
                return(NotFound());
            }

            model.MapToContact(contact);

            await _contactRepository.Update(id, contact);

            return(Ok(contact));
        }