Example #1
0
        public async Task <AudienceDetailsModel> UpdateAsync(Guid id, AudienceUpdateModel model)
        {
            if (id.Equals(Guid.Empty))
            {
                throw new ArgumentNullException(nameof(id));
            }
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }

            var found = await Repository.GetByIdAsync(id);

            if (found == null)
            {
                return(null);
            }


            Mapper.Map <AudienceUpdateModel, Audience>(model, found);
            var updated = await Repository.UpdateAsync(found);

            await Audit.AuditCreatedAsync($"Audience {updated.Name} has been updated");

            return(Mapper.Map <AudienceDetailsModel>(updated));
        }
Example #2
0
        public async Task <IActionResult> UpdateAudienceAsync([FromRoute] Guid id, [FromBody] AudienceUpdateModel model)
        {
            var updated = await Service.UpdateAsync(id, model);

            if (updated == null)
            {
                return(NotFound());
            }
            return(Ok(updated));
        }