Beispiel #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;
        }
Beispiel #2
0
 public ResponseModel<String> ResendValidationCodeService(ValidateAccountRequest req, HttpRequestBase request)
 {
     var response = new ResponseModel<string>();
     if (_db.Users.Any(x => x.Username == req.userName))
     {
         var user = _db.Users.SingleOrDefault(x => x.Username == req.userName);
         if (user != null && (user.isActive == "true"))
         {
             // Account has been already validated.
             response.Status = 402;
             response.Message = "warning";
             return response;
         }
         var guidAlreadyExist = _db.ValidateUserKeys.SingleOrDefault(x => x.Username == req.userName);
         if (guidAlreadyExist != null)
         {
             _db.ValidateUserKeys.Remove(guidAlreadyExist);
         }
         var dbValidateUserKey = new ValidateUserKey
         {
             guid = Guid.NewGuid().ToString(),
             Username = req.userName
         };
         _db.ValidateUserKeys.Add(dbValidateUserKey);
         try
         {
             _db.SaveChanges();
             SendAccountCreationValidationEmail.SendAccountCreationValidationEmailMessage(req.userName, dbValidateUserKey.guid, request);
         }
         catch (DbEntityValidationException e)
         {
             DbContextException.LogDbContextException(e);
             response.Status = 500;
             response.Message = "Internal Server Error !!!";
             return response;
         }
         response.Status = 200;
         response.Message = "success";
         return response;
     }
     // User Doesn't Exist
     response.Status = 404;
     response.Message = "warning";
     return response;
 }
Beispiel #3
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 = 402;
             response.Message = "link expired";
             return response;
         }
         user.isActive = "true";
         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;
 }
Beispiel #4
0
 public JsonResult ValidateAccount(ValidateAccountRequest req)
 {
     return Json(new AuthService().ValidateAccountService(req));
 }
Beispiel #5
0
 public JsonResult ResendValidationCode(ValidateAccountRequest req)
 {
     return Json(new AuthService().ResendValidationCodeService(req, Request));
 }