Exemplo n.º 1
0
        public async Task <IActionResult> Post([FromBody] EmailAccountViewModel viewModel)
        {
            await AuthorizeHostAsync(EmailAccountFunctionName);

            var entity = viewModel.Map <EmailAccountViewModel, EmailAccount>();
            await _emailAccountService.CreateAsync(entity, GetEmbeddedUser(), GetClientIP());

            return(Created(string.Empty, entity.Id));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Put(string id, [FromBody] EmailAccountViewModel viewModel)
        {
            await AuthorizeHostAsync(EmailAccountFunctionName);

            var entity = viewModel.Map <EmailAccountViewModel, EmailAccount>();

            entity.Id = id;

            var result = await _emailAccountService.UpdateAsync(entity, GetEmbeddedUser(), GetClientIP());

            if (!result)
            {
                return(NotFound());
            }

            return(NoContent());
        }