Esempio n. 1
0
        public async Task <GroupDto> GetMyGroup(GetMyGroup command)
        {
            var group = await _groupRepository.GetWholeGroupAsync(command.GroupId);

            if (group == null)
            {
                throw new AppException($"Group doesn't exist", AppErrorCode.DOESNT_EXIST);
            }
            else if (!group.Students.Any(s => s.Id == command.UserId) &&
                     !group.Administrators.Any(a => a.Id == command.UserId))
            {
                throw new AppException("You don't belong to this group", AppErrorCode.CANT_DO_THAT);
            }

            return(CreateFullGroup().Compile().Invoke(group));
        }
Esempio n. 2
0
 public async Task <ActionResult <List <GroupDto> > > GetMyGroup([FromRoute] GetMyGroup command)
 {
     command.UserId = User.GetUserId();
     return(Ok(await _groupService.GetMyGroup(command)));
 }