示例#1
0
        public ResponseModel<String> ValidateAccountService(ValidateAccountRequest req)
        {
            var response = new ResponseModel<string>();
            if (_db.ValidateUserKeys.Any(x => x.Username == req.userName && x.guid == req.guid))
            {
                var user = _db.Users.SingleOrDefault(x => x.Username == req.userName);
                if (user == null)
                {
                    response.Status = 500;
                    response.Message = "Internal Server Error";
                    Logger.Info("Validate Account : " + req.userName);
                    return response;
                }
                if (user.isActive == "true")
                {
                    response.Status = 405;
                    response.Message = "already active user";
                    return response;
                }
                user.isActive = "true";
                var Recommendations = _db.RecommendedBies.SingleOrDefault(x => x.RecommendedTo == user.Username);
                
                new UserMessageService().SendUserNotificationForAccountVerificationSuccess(
                            user.Username, user.Type
                        );

                if (Recommendations != null)
                {
                    Recommendations.isValid = Constants.status_true;
                    var result = new UserReputationService().UpdateUserBalance(Constants.userType_user, Recommendations.RecommendedFromUsername,
                            Constants.newAccountCreationReferralBalanceAmount, 0, 0, Constants.payment_credit, Recommendations.RecommendedTo + " Joined Cautom", "New Account",
                            "Referral Bonus", false);
                    new UserNotificationService().SendUserCommonNotificationAsync(Recommendations.RecommendedFromUsername,Recommendations.RecommendedTo +" Account Validated <br/> Referral Bonus is Credited to your account!",Constants.userType_user);
                }
                    
                try
                {
                    _db.SaveChanges();
                }
                catch (DbEntityValidationException e)
                {
                    DbContextException.LogDbContextException(e);
                    response.Status = 500;
                    response.Message = "Internal Server Error";
                    return response;
                }
                response.Status = 200;
                response.Message = "validated";
                return response;
            }
            response.Status = 402;
            response.Message = "link expired";
            return response;
        }
示例#2
0
 public void AcceptCompleteSurveyTemplateDetailById(string username, long id, string userResponse)
 {
     var response = new ResponseModel<string>();
     try
     {
         var HashMap = new Dictionary<string, double>();
         var surveyDetail =
             _db.CreateTemplateQuestionInfoes.SingleOrDefault(x => x.Id == id && x.username == username);
         if (surveyDetail != null)
         {
             var SurveyResult = GetTemplateSurveyResponseResultById(username, id);                    
             foreach (var resultList in SurveyResult.Payload.resultList)
             {
                 double subTotalResponse = (resultList.resultMap.Sum(x => x.Value));
                 
                 //if (resultList.questionType == Constants.questionTypeSAQ)
                 {
                     foreach (var resultMap in resultList.resultMap)
                     {
                         HashMap[resultList.questionType + resultMap.Key] = Convert.ToDouble(Convert.ToDouble(resultMap.Value) / subTotalResponse);                                
                     }                            
                 }                        
             }
             var userList = _db.UserJobMappings.Where(x => x.refKey == surveyDetail.referenceId).Select(x => x.username).Distinct().ToList();
             foreach (var users in userList)
             {
                 double userReputationTempSum = 0.0;
                 double averageReputation;
                 long totalQuestions = 0;
                 var userAnswerList =
                     _db.UserSurveyResultToBeRevieweds1.Where(x => x.refKey == surveyDetail.referenceId && x.username == users)
                         .ToList();
                 foreach (var userAnswer in userAnswerList)
                 {
                     userReputationTempSum += HashMap[userAnswer.type + userAnswer.answer];
                     totalQuestions++;
                 }
                 if (totalQuestions < 1)
                     totalQuestions = 1;
                 averageReputation = userReputationTempSum/totalQuestions;
                 var result = new UserReputationService().UpdateUserBalance(Constants.userType_user, users,
                     Convert.ToDouble(
                        surveyDetail.payPerUser), 0, averageReputation, Constants.payment_credit, surveyDetail.title, surveyDetail.type,
                     surveyDetail.subType,true);                        
             }
             surveyDetail.verified = Constants.status_accepted;
             try
             {
                 _db.SaveChanges();
             }
             catch (DbEntityValidationException e)
             {
                 DbContextException.LogDbContextException(e);                        
             }
         }
         else
         {
             response.Status = 404;
             response.Message = "Survey id not found !!!";
         }
         
     }
     catch (Exception ex)
     {
         
     }
 }