protected void CreateUser_Click(object sender, EventArgs e) { var manager = Context.GetOwinContext().GetUserManager <ApplicationUserManager>(); var signInManager = Context.GetOwinContext().Get <ApplicationSignInManager>(); var user = new ApplicationUser() { UserName = Username.Text, //Email = Email.Text PhoneNumber = PhoneNumber.Text }; IdentityResult result = manager.Create(user, Password.Text); if (result.Succeeded) { // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771 //string code = manager.GenerateEmailConfirmationToken(user.Id); //string callbackUrl = IdentityHelper.GetUserConfirmationRedirectUrl(code, user.Id, Request); //manager.SendEmail(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>."); // create user User dbUser = new User() { username = user.UserName, teamId = Team.SelectedValue }; RestRequest request = new RestRequest("users/" + dbUser.username, Method.POST); request.AddJsonBody(dbUser); IRestResponse response = RestDispatcher.ExecuteRequest(request); //AmazonSimpleNotificationServiceClient snsClient = new AmazonSimpleNotificationServiceClient(); //Models.Subscription sub = RestDispatcher.ExecuteRequest<Models.Subscription>("subscriptions/" + dbUser.teamId, Method.GET); //if (sub == null) //{ //} //SubscribeRequest subRequ = new SubscribeRequest(sub.topicARN, "sms", user.PhoneNumber); //snsClient.Subscribe(subRequ); signInManager.SignIn(user, isPersistent: false, rememberBrowser: false); IdentityHelper.RedirectToReturnUrl(Request.QueryString["ReturnUrl"], Response); } else { ErrorMessage.Text = result.Errors.FirstOrDefault(); } }
public IHttpActionResult GetContribution(string id) { DynamoDBContext context = new DynamoDBContext(dynamoClient); User dbUser = context.Load <User>(id); if (dbUser == null) { return(NotFound()); } Team dbTeam = context.Load <Team>(dbUser.teamId); if (dbTeam == null) { return(NotFound()); } Battle dbBattle = context.Load <Battle>(dbTeam.currentBattle); if (dbBattle == null) { return(NotFound()); } int index = 0; for (; index < dbBattle.participants.Count; index++) { if (dbBattle.participants[index].Equals(dbUser.teamId)) { break; } } dbBattle.scores[index] += dbBattle.offsets[index]; // dbBattle.participants[dbUser.teamId] += 1; context.Save <Battle>(dbBattle); Guid contribGuid = new Guid(); Contribution newContrib = new Contribution() { contributionId = contribGuid.ToString(), username = dbUser.username, teamId = dbUser.teamId, battleId = dbBattle.battleId }; //RestRequest requ = new RestRequest("contributions/user/" + dbUser.username + "/battle/" + dbBattle.battleId, Method.GET); RestRequest contribPost = new RestRequest("contributions", Method.POST); contribPost.AddJsonBody(newContrib); Contribution userContrib = RestDispatcher.ExecuteRequest <Contribution>(contribPost); return(Ok(userContrib)); }