예제 #1
0
        [HttpGet] public async Task <string> SendText(string id, string key, string txt)
        {
            var corrected = await CorrectText(txt);

            APIModels check         = JsonConvert.DeserializeObject <APIModels>(corrected);
            string    correctedText = txt;

            foreach (FlaggedToken correction in check.flaggedTokens)
            {
                correctedText = correctedText.Replace(correction.token, correction.suggestions.ToList()[0].suggestion);
                Console.WriteLine(correction.suggestions.ToList()[0].suggestion);
            }

            //var commentString = JsonConvert.SerializeObject(commentDataPoint);
            //var message = new Microsoft.Azure.Devices.Client.Message(Encoding.ASCII.GetBytes(commentString));

            //var deviceClient = DeviceClient.Create(iotHubUri, new DeviceAuthenticationWithRegistrySymmetricKey(id, key));

            //await deviceClient.SendEventAsync(message);

            Response.StatusCode = 200; // OK = 200
            return(correctedText);
            //return Json(check, JsonRequestBehavior.AllowGet);
            //return JsonConvert.SerializeObject(check.flaggedTokens);
            //return corrected;
        }
예제 #2
0
        public async Task<SetTeamOrAdjudicatorResult> DeleteAdjudicator(APIModels.Adjudicator adjudicator)
        {
            var ident = HttpContext.Current.User.Identity as ClaimsIdentity;
            String userId = ident.GetUserId();
            var user = await userManager.FindByIdAsync(userId);

            // Check if user has permissions


            if (adjudicator.organizationId == null
                || !userManager.HasOrganizationRole(userId, (Guid)adjudicator.organizationId, DebReg.Models.OrganizationRole.Delegate))
            {
                // User does not have permissions
                return SetTeamOrAdjudicatorResult.NotAuthorized;
            }

            var result = tournamentRegistrationsManager.RemoveAdjudicator(adjudicator.tournamentId, adjudicator.userId, user);
            return result;
        }