Esempio n. 1
0
 public NewUserAchievement SubmitAchievement(NewUserAchievementRequest newAchievementRequest)
 {
     using (SqlConnection connection = new SqlConnection(_connectionString))
     {
         if (!UserAchievementExists(newAchievementRequest.AchievementId, newAchievementRequest.UserId))
         {
             var newAchievement = new NewUserAchievement()
             {
                 UserId        = newAchievementRequest.UserId,
                 AchievementId = newAchievementRequest.AchievementId,
                 Link          = newAchievementRequest.Link,
                 IsApproved    = false,
                 IsPending     = true,
                 DateSubmitted = DateTime.Now
             };
             var queryString = @"Insert into UserAchievement(UserId, AchievementId, Link, IsPending, IsApproved, DateSubmitted)
                             Output inserted.*
                             Values(@UserId, @AchievementId, @Link, @IsPending, @IsApproved, @DateSubmitted)";
             var achievement = connection.QueryFirstOrDefault <NewUserAchievement>(queryString, newAchievement);
             return(achievement);
         }
     }
     throw new Exception("Could not post new achievement.");
 }
Esempio n. 2
0
        public ActionResult SubmitAchievement(NewUserAchievementRequest newAchievement)
        {
            var achievement = _connection.SubmitAchievement(newAchievement);

            return(Accepted(achievement));
        }