public async Task <IActionResult> Create(GroupByAdmin newGroupByAdmin)
        {
            GroupByAdminValidator validator = new GroupByAdminValidator(this._groupService);
            ValidationResult      results   = await validator.ValidateAsync(newGroupByAdmin);

            results.AddToModelState(ModelState, "GroupByAdmin");

            if (!ModelState.IsValid)
            {
                return(BadRequest(this.ModelState));
            }

            int groupId = await this._groupService.CreateByAdmin(newGroupByAdmin);

            return(Ok(newGroupByAdmin));
        }
        public async Task <int> CreateByAdmin(GroupByAdmin newGroupByAdmin)
        {
            var newGroup = new Group
            {
                Name      = newGroupByAdmin.Name,
                CreatedAt = DateTime.Now
            };

            await this.groupRepository.Insert(newGroup);

            Group group = await this.groupRepository.GetByName(newGroup.Name);

            await this.CreateAcceptedMembership(true, group, newGroupByAdmin.CreatorId);

            foreach (var membershipId in newGroupByAdmin.MembersId)
            {
                await this.CreateAcceptedMembership(false, group, membershipId);
            }

            return(group.Id);
        }