Пример #1
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);
        }