Пример #1
0
        public static ResponseDto ChangeProfilePhoto(ChangeProfilePhotoRequest request)
        {
            ResponseDto response  = new ResponseDto();
            AgentBoss   agentBoss = null;

            try
            {
                //if (!AgentBossServices.CheckAgentBoss(request.user_id, request.auth_token, response))
                //{
                //    return response;
                //}
                using (AgentBossDao dao = new AgentBossDao())
                {
                    agentBoss = dao.FindById(request.user_id);
                    if (agentBoss != null)
                    {
                        agentBoss.ProfileImage = request.profile_image;
                        dao.Update(agentBoss);
                    }
                    response.code         = 0;
                    response.has_resource = 1;
                    response.message      = MessagesSource.GetMessage("profile.changed");
                    return(response);
                }
            }
            catch (Exception ex)
            {
                response.MakeExceptionResponse(ex);
                return(response);
            }
        }
Пример #2
0
        public static ResponseDto ChangeProfile(ChangeProfileAgentBossRequest request)
        {
            request.mobile_number = Common.GetStandardMobileNumber(request.mobile_number);
            ResponseDto response  = new ResponseDto();
            AgentBoss   agentBoss = null;

            try
            {
                if (!AgentBossServices.CheckAgentBoss(request.user_id, request.auth_token, response))
                {
                    return(response);
                }
                using (AgentBossDao dao = new AgentBossDao())
                {
                    agentBoss           = dao.FindById(request.user_id);
                    agentBoss.OwnerName = request.agent_boss_name;
                    //agentBoss.MobileNumber = request.mobile_number;
                    //agentBoss.ProfileImage = request.profile_image; //Commented bcz image is uploading as multipart
                    agentBoss.Email = request.agent_boss_email;
                    dao.Update(agentBoss);
                    response.code         = 0;
                    response.has_resource = 1;
                    response.message      = MessagesSource.GetMessage("profile.changed");
                    return(response);
                }
            }
            catch (Exception ex)
            {
                response.MakeExceptionResponse(ex);
                return(response);
            }
        }
Пример #3
0
        public static LoginResponse Login(LoginRequest request)
        {
            request.mobile_number = Common.GetStandardMobileNumber(request.mobile_number);
            LoginResponse response  = new LoginResponse();
            AgentBoss     agentBoss = null;

            try
            {
                using (AgentBossDao dao = new AgentBossDao())
                {
                    string hashPassword = TokenGenerator.GetHashedPassword(request?.password, 49);
                    agentBoss = dao.FindByMobileNumber(request.mobile_number);
                    if (agentBoss == null)
                    {
                        MakeNouserResponse(response);
                        return(response);
                    }
                    if (hashPassword == agentBoss.Password)
                    {
                        response.code         = 1;
                        response.has_resource = 0;
                        //admin. = request.app_id;
                        agentBoss.AppToken  = request.push_token;
                        agentBoss.AppID     = request.app_id;
                        agentBoss.LastLogin = DateTime.Now;
                        string authToken = TokenGenerator.GenerateToken(agentBoss.OwnerName, agentBoss.Password, request.mobile_number);
                        agentBoss.AccToken = authToken;
                        dao.Update(agentBoss);
                        response.code = 0;
                        AgentBossLoginDto dto = new AgentBossLoginDto();
                        AgentBossHelper.CopyFromEntity(dto, agentBoss);
                        response.code         = 0;
                        response.message      = MessagesSource.GetMessage("login.ok");
                        response.has_resource = 1;
                        response.user_login   = dto;
                        return(response);
                    }
                    else
                    {
                        response.code         = 1;
                        response.has_resource = 0;
                        response.message      = MessagesSource.GetMessage("login.fail");
                    }
                }
            }
            catch (Exception ex)
            {
                response.MakeExceptionResponse(ex);
            }
            return(response);
        }
Пример #4
0
        //public static ResendOtpResponse ResendOtp(ResendOtpRequest request)
        //{
        //    ResendOtpResponse response = new ResendOtpResponse();
        //    response.otp_details = new OtpDetailsDto();
        //    AgentBoss agentBoss = null;
        //    try
        //    {
        //        using (AgentBossDao userDao = new AgentBossDao())
        //        {
        //            // agentBoss = GetAuthAgentBoss(request.user_id, request.auth_token, response);
        //            agentBoss = userDao.FindByMobileNumber(request.mobile_number);
        //        }
        //        if (agentBoss == null)
        //        {
        //            MakeNouserResponse(response);
        //            return response;
        //        }

        //        OTPServices.ResendOTP(agentBoss.AbosID, agentBoss.MobileNumber, "B");
        //        response.code = 0;
        //        response.has_resource = 1;
        //        response.message = MessagesSource.GetMessage("otp.resent");
        //        response.otp_details.send_otp = 1;
        //        return response;
        //    }
        //    catch (Exception ex)
        //    {
        //        response.MakeExceptionResponse(ex);
        //        return response;
        //    }
        //}

        public static ResponseDto ResetPassword(ResetPasswordRequest request)
        {
            request.mobile_number = Common.GetStandardMobileNumber(request.mobile_number);
            ResponseDto response            = new ResponseDto();
            AgentBoss   agentBoss           = null;
            string      newPasswordHash     = TokenGenerator.GetHashedPassword(request.new_password, 49);
            string      confirmPasswordHash = TokenGenerator.GetHashedPassword(request.confirm_password, 49);

            try
            {
                //if (!AgentBossServices.CheckAgentBoss(request.user_id, request.auth_token, response))
                //if (!AgentBossServices.CheckAgentBossNotAuthToken(request.user_id, response))
                //{
                //    return response;
                //}
                using (AgentBossDao dao = new AgentBossDao())
                {
                    agentBoss = dao.FindByMobileNumber(request.mobile_number);
                    //agentBoss = dao.FindById(request.user_id);
                    if (agentBoss == null)
                    {
                        MakeNouserResponse(response);
                        return(response);
                    }
                    if (newPasswordHash == confirmPasswordHash)
                    {
                        agentBoss.Password = TokenGenerator.GetHashedPassword(request.new_password, 49);
                        dao.Update(agentBoss);
                        response.code         = 0;
                        response.has_resource = 1;
                        response.message      = MessagesSource.GetMessage("passwd.reset");
                        return(response);
                    }
                }
                response.code         = 1;
                response.has_resource = 0;
                response.message      = MessagesSource.GetMessage("exception");
                return(response);
            }
            catch (Exception ex)
            {
                response.MakeExceptionResponse(ex);
                return(response);
            }
        }
Пример #5
0
        public static ResponseDto CheckOTP(CheckOtpRequest request)
        {
            request.mobile_number = Common.GetStandardMobileNumber(request.mobile_number);
            ResponseDto response  = new ResponseDto();
            AgentBoss   agentBoss = null;

            response.has_resource = 0;
            try
            {
                using (AgentBossDao dao = new AgentBossDao())
                {
                    agentBoss = dao.FindByMobileNumber(request.mobile_number);
                    //agentBoss = GetAuthAgentBoss(request.user_id, request.auth_token, response);
                    //agentBoss = GetAuthAgentBossNotAuthToken(request.user_id, response);
                    if (agentBoss == null)
                    {
                        MakeNouserResponse(response);
                        return(response);
                    }


                    bool otpValid = OTPServices.ValidateOTP(agentBoss.AbosID, request.otp_code);
                    OTPServices.RemoveOTP(agentBoss.AbosID, request.otp_code);// Either way remove this otp if it exists.
                    if (otpValid)
                    {
                        agentBoss.StatusId = true;
                        dao.Update(agentBoss);
                        response.code         = 0;
                        response.message      = MessagesSource.GetMessage("otp.valid");
                        response.has_resource = 1;
                        return(response);
                    }
                    response.code    = 1;
                    response.message = MessagesSource.GetMessage("otp.not.valid");
                    return(response);
                }
            }
            catch (Exception ex)
            {
                response.MakeExceptionResponse(ex);
            }
            return(response);
        }
Пример #6
0
        public static ResponseDto ChangePassword(ChangePasswordAgentBossRequest request)
        {
            ResponseDto response        = new ResponseDto();
            AgentBoss   agentBoss       = null;
            string      oldPasswordHash = TokenGenerator.GetHashedPassword(request.old_password, 49);

            try
            {
                if (!AgentBossServices.CheckAgentBoss(request.user_id, request.auth_token, response))
                {
                    MakeNouserResponse(response);
                    return(response);
                }
                using (AgentBossDao dao = new AgentBossDao())
                {
                    agentBoss = dao.FindById(request.user_id);
                    if (agentBoss.Password == oldPasswordHash)
                    {
                        agentBoss.Password = TokenGenerator.GetHashedPassword(request.new_password, 49);
                        dao.Update(agentBoss);
                        response.code         = 0;
                        response.has_resource = 1;
                        response.message      = MessagesSource.GetMessage("password.changed");
                        return(response);
                    }
                }
                response.code         = 1;
                response.has_resource = 0;
                response.message      = MessagesSource.GetMessage("exception");
                return(response);
            }
            catch (Exception ex)
            {
                response.MakeExceptionResponse(ex);
                return(response);
            }
        }