private IEnumerator _CreateGroup()
    {
        if (!CheckFields())
        {
            AlertsService.makeAlert("Campos inválidos", "Preencha os campos corretamente.", "OK");
            yield break;
        }

        AlertsService.makeLoadingAlert("Criando grupo");

        string groupName        = newGroupName.text,
               groupDescription = newGroupDescription.text;

        WWW createRequest = GroupsService.CreateGroup(groupName, groupDescription);

        while (!createRequest.isDone)
        {
            yield return(new WaitForSeconds(0.1f));
        }

        Debug.Log("Header: " + createRequest.responseHeaders["STATUS"]);
        Debug.Log("Text: " + createRequest.text);

        if (createRequest.responseHeaders["STATUS"] == HTML.HTTP_200)
        {
            GroupsService.UpdateCurrentGroup(createRequest.text);
            yield return(StartCoroutine(_AddOwnership()));
        }
        else
        {
            AlertsService.makeAlert("Falha na conexão", "Tente novamente mais tarde.", "Entendi");
        }

        yield return(null);
    }
Esempio n. 2
0
        // Create a new group. It can be an Office 365 group, dynamic group, or security group.
        // This snippet creates an Office 365 (unified) group.
        // This snippet requires an admin work account.
        public async Task <ActionResult> CreateGroup()
        {
            ResultsViewModel results = new ResultsViewModel();

            try
            {
                // Add the group.
                results.Items = await groupsService.CreateGroup();
            }
            catch (ServiceException se)
            {
                if ((se.InnerException as AuthenticationException)?.Error.Code == Resource.Error_AuthChallengeNeeded)
                {
                    HttpContext.Request.GetOwinContext().Authentication.Challenge();
                    return(new EmptyResult());
                }
                return(RedirectToAction("Index", "Error", new { message = string.Format(Resource.Error_Message, Request.RawUrl, se.Error.Code, se.Error.Message) }));
            }
            return(View("Groups", results));
        }
Esempio n. 3
0
        // Create a new group. It can be an Office 365 group, dynamic group, or security group.
        // This snippet creates an Office 365 (unified) group.
        // This snippet requires an admin work account.
        public async Task <ActionResult> CreateGroup()
        {
            ResultsViewModel results = new ResultsViewModel();

            try
            {
                // Initialize the GraphServiceClient.
                GraphServiceClient graphClient = SDKHelper.GetAuthenticatedClient();

                // Add the group.
                results.Items = await groupsService.CreateGroup(graphClient);
            }
            catch (ServiceException se)
            {
                if (se.Error.Message == Resource.Error_AuthChallengeNeeded)
                {
                    return(new EmptyResult());
                }
                return(RedirectToAction("Index", "Error", new { message = string.Format(Resource.Error_Message, Request.RawUrl, se.Error.Code, se.Error.Message) }));
            }
            return(View("Groups", results));
        }
Esempio n. 4
0
        public IActionResult Create(CreateGroupModel model)
        {
            if (model == null)
            {
                return(BadRequest());
            }
            if (!ModelState.IsValid)
            {
                return(Ok(Json(ModelState
                               .Where(s => s.Value.Errors.Any())
                               .Select(s => new { Key = s.Key, Error = s.Value.Errors.Select(e => e.ErrorMessage).FirstOrDefault() }))));
            }

            var userId = User.FindFirstValue(ClaimTypes.NameIdentifier);

            int?   universityId = null;
            string password     = null;

            if (model.RequirePassword)
            {
                password = model.Password;
            }
            if (model.RequireUniversity)
            {
                universityId = model.UniversityId;

                if (!_universitiesService.IsMember(model.UniversityId.Value, userId))
                {
                    return(BadRequest(Json("You are not a member of a selected university")));
                }
            }

            _groupsService.CreateGroup(userId, model.Name, universityId, password);

            return(Ok(Json(new { Redirect = Url.Action("Index", "Home") })));
        }