示例#1
0
        public static ResponseDto ChangeProfilePhoto(ChangeProfilePhotoRequest request)
        {
            ResponseDto response = new ResponseDto();
            AgentAdmin  admin    = null;

            try
            {
                //if (!AgentAdminServices.CheckAdmin(request.user_id, request.auth_token, response))
                //{
                //    return response;
                //}
                using (AgentAdminDao dao = new AgentAdminDao())
                {
                    admin = dao.FindById(request.user_id);
                    if (admin != null)
                    {
                        admin.ProfileImage = request.profile_image;
                        dao.Update(admin);
                    }
                    response.code         = 0;
                    response.has_resource = 0;
                    response.message      = MessagesSource.GetMessage("profile.changed");
                    return(response);
                }
            }
            catch (Exception ex)
            {
                response.MakeExceptionResponse(ex);
                return(response);
            }
        }
示例#2
0
        public static GetAgentAdminDetailsResponse GetDetails(GetAgentAdminDetailsRequest request)
        {
            GetAgentAdminDetailsResponse response = new GetAgentAdminDetailsResponse();
            AgentAdmin admin = null;

            try
            {
                if (!AgentAdminServices.CheckAdmin(request.user_id, request.auth_token, response))
                {
                    return(response);
                }
                using (AgentAdminDao dao = new AgentAdminDao())
                {
                    admin = dao.FindById(request.user_id);
                    response.agent_admin_details = new AgentAdminDetailsDto();
                    response.agent_admin_details.agent_admin_id    = admin.AgadmID;
                    response.agent_admin_details.agent_admin_name  = admin.AgentAdminName;
                    response.agent_admin_details.mobile_number     = admin.MobileNumber;
                    response.agent_admin_details.profile_image     = ImagePathService.agentAdminImagePath + admin.ProfileImage;
                    response.agent_admin_details.agent_admin_email = admin.email;
                    response.code         = 0;
                    response.has_resource = 1;
                    response.message      = MessagesSource.GetMessage("admin.details");
                    return(response);
                }
            }
            catch (Exception ex)
            {
                response.MakeExceptionResponse(ex);
                return(response);
            }
        }
示例#3
0
        public static ResponseDto ChangeProfile(ChangeProfileAgentAdminRequest request)
        {
            request.mobile_number = Common.GetStandardMobileNumber(request.mobile_number);
            ResponseDto response = new ResponseDto();
            AgentAdmin  admin    = null;

            try
            {
                if (!AgentAdminServices.CheckAdmin(request.user_id, request.auth_token, response))
                {
                    return(response);
                }
                using (AgentAdminDao dao = new AgentAdminDao())
                {
                    admin = dao.FindById(request.user_id);
                    admin.AgentAdminName = request.agent_admin_name;
                    //admin.MobileNumber = request.mobile_number;
                    //admin.ProfileImage = string.IsNullOrWhiteSpace(request.profile_image) ? admin.ProfileImage : request.profile_image; //Commented bcz image is uploading as multipart
                    admin.email = request.agent_admin_email;
                    dao.Update(admin);
                    response.code         = 0;
                    response.has_resource = 0;
                    response.message      = MessagesSource.GetMessage("profile.changed");
                    return(response);
                }
            }
            catch (Exception ex)
            {
                response.MakeExceptionResponse(ex);
                return(response);
            }
        }
示例#4
0
        public static AgentAdmin GetAuthAdmin(int userId, string authToken, ResponseDto response = null)
        {
            AgentAdmin admin = null;

            using (AgentAdminDao dao = new AgentAdminDao())
            {
                admin = dao.FindById(userId);
                if (admin != null && admin.AccToken == authToken)
                {
                    return(admin);
                }
                if (response != null)
                {
                    response.code         = 1;
                    response.has_resource = 0;
                    response.message      = MessagesSource.GetMessage("invalid.admin");
                }
                return(null);
            }
        }
示例#5
0
        public static ResponseDto ChangePassword(ChangePasswordAgentAdminRequest request)
        {
            ResponseDto response        = new ResponseDto();
            AgentAdmin  admin           = null;
            string      oldPasswordHash = TokenGenerator.GetHashedPassword(request.old_password, 49);

            try
            {
                if (!AgentAdminServices.CheckAdmin(request.user_id, request.auth_token, response))
                {
                    return(response);
                }
                using (AgentAdminDao dao = new AgentAdminDao())
                {
                    admin = dao.FindById(request.user_id);
                    if (admin.Password == oldPasswordHash)
                    {
                        admin.Password = TokenGenerator.GetHashedPassword(request.new_password, 49);
                        dao.Update(admin);
                        response.code         = 0;
                        response.has_resource = 0;
                        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);
            }
        }