Ejemplo n.º 1
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;
 }
Ejemplo n.º 2
0
        public ResponseModel<String> WebRegisterService(RegisterationRequest req, HttpRequestBase request)
        {            
            var response = new ResponseModel<String>();
            if (_db.Users.Any(x => x.Username == req.Username))
            {
                response.Status = 409;
                response.Message = "conflict";
                return response;
            }

            var guid = Guid.NewGuid().ToString();
            var user = new User
            {
                Username = req.Username,
                Password = EncryptionClass.Md5Hash(req.Password),
                Source = req.Source,
                isActive = "false",
                Type = req.Type,
                guid = Guid.NewGuid().ToString(),
                fixedGuid= Guid.NewGuid().ToString(),
                FirstName = req.FirstName,
                LastName = req.LastName,
                gender = "NA",
                ImageUrl = "NA"
            };
            _db.Users.Add(user);
            
            if (!Constants.NA.Equals(req.Referral))
            {
                new ReferralService().payReferralBonusAsync(req.Referral, req.Username,Constants.status_false);
            }
            if (req.Type == "client")
            {
                var dbClientDetails = new ClientDetail
                {
                    Username = req.Username,
                    CompanyName =  string.IsNullOrEmpty(req.CompanyName)?"NA":req.CompanyName
                };
                _db.ClientDetails.Add(dbClientDetails);
            }
            var dbValidateUserKey = new ValidateUserKey
            {
                Username = req.Username,
                guid = guid
            };

            _db.ValidateUserKeys.Add(dbValidateUserKey);

            try
            {
                _db.SaveChanges();
                var signalRHub = new SignalRHub();
                string totalProjects = "";
                string successRate = "";
                string totalUsers = _db.Users.Count().ToString(CultureInfo.InvariantCulture);
                string projectCategories = "";
                var hubContext = GlobalHost.ConnectionManager.GetHubContext<SignalRHub>();
                hubContext.Clients.All.updateBeforeLoginUserProjectDetails(totalProjects, successRate, totalUsers, projectCategories);
                SendAccountCreationValidationEmail.SendAccountCreationValidationEmailMessage(req.Username, guid, request);
            }
            catch (DbEntityValidationException e)
            {
                DbContextException.LogDbContextException(e);
                response.Status = 500;
                response.Message = "Internal Server Error !!!";
                return response;
            }

            response.Status = 200;
            response.Message = "success";
            response.Payload = "Account Created";

            return response;
        }
Ejemplo n.º 3
0
        public ResponseModel<String> WebRegisterService(RegisterationRequest req, HttpRequestBase request)
        {
            var response = new ResponseModel<String>();
            if (_db.Users.Any(x => x.Username == req.Username))
            {
                response.Status = 409;
                response.Message = "conflict";
                return response;
            }

            var guid = Guid.NewGuid().ToString();
            var user = new User
            {
                Username = req.Username,
                Password = EncryptionClass.Md5Hash(req.Password),
                Source = req.Source,
                isActive = "false",
                Type = req.Type,
                guid = Guid.NewGuid().ToString(),
                FirstName = req.FirstName,
                LastName = req.LastName,
                gender = "NA",
                ImageUrl = "NA"
            };
            _db.Users.Add(user);

            if (!string.IsNullOrEmpty(req.Referral))
            {
                var dbRecommedBy = new RecommendedBy
                {
                    RecommendedFrom = req.Referral,
                    RecommendedTo = req.Username
                };
                _db.RecommendedBies.Add(dbRecommedBy);
            }
            if (req.Type == "client")
            {
                var dbClientDetails = new ClientDetail
                {
                    Username = req.Username,
                    CompanyName = req.CompanyName
                };
                _db.ClientDetails.Add(dbClientDetails);
            }
            var dbValidateUserKey = new ValidateUserKey
            {
                Username = req.Username,
                guid = guid
            };

            _db.ValidateUserKeys.Add(dbValidateUserKey);

            try
            {
                _db.SaveChanges();
                SendAccountCreationValidationEmail.SendAccountCreationValidationEmailMessage(req.Username, guid, request);
            }
            catch (DbEntityValidationException e)
            {
                DbContextException.LogDbContextException(e);
                response.Status = 500;
                response.Message = "Internal Server Error !!!";
                return response;
            }

            response.Status = 200;
            response.Message = "success";
            response.Payload = "Account Created";

            return response;
        }