コード例 #1
0
        public async Task <ActionResult> JoinGroup(Guid hash)
        {
            var group = groupsRepo.FindGroupByInviteHash(hash);

            if (group == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.NotFound));
            }

            if (Request.HttpMethod == "POST")
            {
                var alreadyInGroup = await groupsRepo.AddUserToGroup(group.Id, User.Identity.GetUserId()) == null;

                if (!alreadyInGroup)
                {
                    await NotifyAboutUserJoinedToGroup(group, User.Identity.GetUserId());
                }

                await slideCheckingsRepo.ResetManualCheckingLimitsForUser(group.CourseId, User.Identity.GetUserId()).ConfigureAwait(false);

                return(View("JoinedToGroup", group));
            }

            return(View(group));
        }