void CompleteChallenge() { CompletedChallenge completedChallenge = new CompletedChallenge(); completedChallenge.ChallengeId = GameManager.me.currentChallengeId; completedChallenge.UserId = GameManager.me.userId; completedChallenge.PhotoId = photoId; completedChallenge.CompletedAt = DateTime.Now; string output = JsonConvert.SerializeObject(completedChallenge); Dictionary <string, string> headers = new Dictionary <string, string>(); headers.Add("content-type", "appication/json"); byte[] data = Encoding.ASCII.GetBytes(output.ToCharArray()); WWW www = new WWW(completeChallengesURL); StartCoroutine(CompleteChallengeCoroutine(www)); }
public async Task CompleteChallenge(Challenge challenge, ApplicationUser user) { using (db = new AthenaDataContext()) { var previouslyCompleted = await db.CompletedChallenges .Where(c => c.ChallengeId == challenge.Id && c.ApplicationUserId == user.Id) .FirstOrDefaultAsync(); if (previouslyCompleted != null) { return; } var completedChallenge = new CompletedChallenge { ChallengeId = challenge.Id, ApplicationUserId = user.Id }; db.CompletedChallenges.Add(completedChallenge); await db.SaveChangesAsync(); } }
void CompleteChallenge() { CompletedChallenge completedChallenge = new CompletedChallenge(); completedChallenge.ChallengeId = GameManager.me.currentChallengeId; completedChallenge.UserId = GameManager.me.userId; completedChallenge.PhotoId = photoId; completedChallenge.CompletedAt = DateTime.Now; string output = JsonConvert.SerializeObject(completedChallenge); Dictionary<string, string> headers = new Dictionary<string, string>(); headers.Add("content-type", "appication/json"); byte[] data = Encoding.ASCII.GetBytes(output.ToCharArray()); WWW www = new WWW(completeChallengesURL); StartCoroutine(CompleteChallengeCoroutine(www)); }