Ejemplo n.º 1
0
        public async Task <Tag> Update([FromBody] Tag model)
        {
            _logger.LogInformation($"update.tag ${model.Id}");
            Tk.AssertValidIds(model.Id);
            var data = await _repository.UpdateAsync(model);

            _logger.LogInformation($"updated.tag ${data.Id}");
            return(data);
        }
Ejemplo n.º 2
0
        public async Task <EventViewModel> Update([FromBody] EventViewModel model)
        {
            _logger.LogInformation($"update.event ${model.Id}");
            Tk.AssertValidIds(model.Id);
            var data = await _service.UpdateAsync(model);

            _logger.LogInformation($"updated.event ${data.Id}");
            return(data);
        }
Ejemplo n.º 3
0
        public async Task <ContactViewModel> Update([FromBody] ContactViewModel model)
        {
            // TODO Do some validation
            _logger.LogInformation($"update.contact ${model.Id}");
            Tk.AssertValidIds(model.Id);
            var data = await _contactService.UpdateAsync(model);

            _logger.LogInformation($"updated.contact ${data.Id}");
            return(data);
        }
Ejemplo n.º 4
0
        public async Task <MemberViewModel> UpdateMember([FromBody] MemberViewModel model)
        {
            Tk.AssertValidIds(model.GroupId, model.ContactId);
            _logger.LogInformation($"update.groupMember Group: {model.GroupId} Contact: {model.ContactId}");
            var toSave = _mapper.Map <Member>(model);
            var data   = await _repository.UpdateAsync(toSave);

            _logger.LogInformation($"updated.groupMember ${data.Id}");
            return(_mapper.Map <MemberViewModel>(data));
        }
Ejemplo n.º 5
0
        public async Task <object> Delete(Guid id)
        {
            _logger.LogInformation($"delete.contact ${id}");
            Tk.AssertValidIds(id);
            var data = await _contactService.DeleteAsync(id);

            _logger.LogInformation($"delete.contact ${id} result: {data}");
            return(new
            {
                Message = "Operation successful"
            });
        }
Ejemplo n.º 6
0
        public async Task <object> Delete(Guid id)
        {
            _logger.LogInformation($"delete.groupMember ${id}");
            Tk.AssertValidIds(id);
            var data = await _repository.DeleteAsync(id);

            _logger.LogInformation($"delete.groupMember ${id} result: {data}");
            return(new
            {
                Message = "Operation successful"
            });
        }
Ejemplo n.º 7
0
        public async Task <object> Get(Guid id)
        {
            _logger.LogInformation($"get.event ${id}");
            Tk.AssertValidIds(id);
            var data = await _service.GetByIdAsync(id);

            if (data == null)
            {
                throw new NotFoundException($"invalid record id: {id}");
            }
            _logger.LogInformation($"got.event ${data.Id}");
            return(data);
        }
Ejemplo n.º 8
0
        public async Task <MemberViewModel> CreateMember([FromBody] CreateMemberModel model)
        {
            Tk.AssertValidIds(model.GroupId, model.ContactId);
            var userId = _httpContextAccessor.GetContactId();

            model.CreatedBy = userId;
            _logger.LogInformation($"create.groupMember Group: {model.GroupId} Contact: {model.ContactId}");
            var toSave = _mapper.Map <Member>(model);
            var data   = await _repository.CreateAsync(toSave);

            _logger.LogInformation($"created.groupMember ${data.Id}");
            return(_mapper.Map <MemberViewModel>(data));
        }
Ejemplo n.º 9
0
        public async Task <CreateMembersModel> Create([FromBody] CreateMembersModel model)
        {
            Tk.AssertValidIds(model.GroupId);
            Tk.AssertValidIds(model.ContactIds.ToArray());
            var userId = _httpContextAccessor.GetContactId();

            model.CreatedBy = userId;
            _logger.LogInformation($"create.groupMember ${model.GroupId}");
            var toSave = model.ContactIds.Select(it => new Member
            {
                GroupId   = model.GroupId,
                ContactId = it,
                Role      = model.Role,
                Status    = GroupStatus.Active
            }).ToList();
            var data = await _repository.CreateBatchAsync(toSave);

            _logger.LogInformation($"created.groupMember ${data.Count()}");
            return(model);
        }