Exemplo n.º 1
0
 def post(self):
     json_values = {}
     
     try:
         code = self.request.get('code')
         pwd = self.request.get('pwd')
         
         if code is None or len(code) < 1:
             raise Exception('You must enter an Agent ID.')
         
         if pwd is None or len(pwd) < 1:
             raise Exception('You must enter a Password.')
         
         vm = AgentViewModel()
         vm.code = code
         vm.pwd = pwd
         
         app_service = AccountAppService()
         app_service.login(vm)
         
         # save to session
         self.session['agent_code'] = vm.code
         
         json_values['returnStatus'] = True
     except Exception, ex:
         json_values['returnStatus'] = False
         json_values['returnMessage'] = str(ex)
Exemplo n.º 2
0
 def agent_login(self):
     try:
         vm = AgentViewModel()
         vm.code = '1'
         vm.pwd = '1'
         
         app_service = AgentAccountAppService()
         app_service.login(vm)
         
         self.response.write("agent_login OK.")
     
     except Exception, ex:
         self.response.write("agent_login failed. %s" % str(ex))
Exemplo n.º 3
0
    def agent_login(self):
        try:
            vm = AgentViewModel()
            vm.code = '1'
            vm.pwd = '1'

            app_service = AgentAccountAppService()
            app_service.login(vm)

            self.response.write("agent_login OK.")

        except Exception, ex:
            self.response.write("agent_login failed. %s" % str(ex))
Exemplo n.º 4
0
 def post(self):
     json_values = {}
     
     try:
         current_agent = self.current_agent()
         
         pwd = self.request.get('newPwd')
         old_pwd = self.request.get('oldPwd')
   
         vm = AgentViewModel()
         vm.code = current_agent.code
         vm.pwd = pwd
         vm.old_pwd = old_pwd
         
         app_service = AccountAppService()
         app_service.change_pwd(vm)
         
         json_values['returnStatus'] = True
     except Exception, ex:
         json_values['returnStatus'] = False
         json_values['returnMessage'] = str(ex)
Exemplo n.º 5
0
    def update_agent(self):
        try:
            data = Agent.query(ancestor=ndb.Key('Agent', '1')).get()

            vm = AgentViewModel()
            vm.code = '1'
            vm.name = '2'
            vm.account_type = 1
            vm.comm_per = 5
            vm.credit_limit = -100
            vm.last_modified = data.last_modified

            app_service = AgentAppService()
            app_service.update(vm)

            self.response.write("update_agent OK.")

        except Exception, ex:
            self.response.write("update_agent failed. %s" % str(ex))
Exemplo n.º 6
0
    def create_agent(self):
        try:
            vm = AgentViewModel()
            vm.code = '1'
            vm.name = '1'
            vm.pwd = '1'
            vm.account_type = 1
            vm.comm_per = 5

            app_service = AgentAppService()
            app_service.create(vm)

            self.response.write("create_agent OK.")

        except Exception, ex:
            self.response.write("create_agent failed. %s" % str(ex))
Exemplo n.º 7
0
 def update_agent(self):
     try:
         data = Agent.query(ancestor=ndb.Key('Agent', '1')).get()
         
         vm = AgentViewModel()
         vm.code = '1'
         vm.name = '2'
         vm.account_type = 1
         vm.comm_per = 5
         vm.credit_limit = -100
         vm.last_modified = data.last_modified
         
         app_service = AgentAppService()
         app_service.update(vm)
         
         self.response.write("update_agent OK.")
         
     except Exception, ex:
         self.response.write("update_agent failed. %s" % str(ex))
Exemplo n.º 8
0
 def create_agent(self):
     try:
         vm = AgentViewModel()
         vm.code = '1'
         vm.name = '1'
         vm.pwd = '1'
         vm.account_type = 1
         vm.comm_per = 5
         
         app_service = AgentAppService()
         app_service.create(vm)
         
         self.response.write("create_agent OK.")
         
     except Exception, ex:
         self.response.write("create_agent failed. %s" % str(ex))
Exemplo n.º 9
0
 def post(self):
     json_values = {}
     
     try:
         # get post data
         name = self.request.get("name")
         code = self.request.get("code")
         pwd = self.request.get("pwd")
         address = self.request.get("address")
         tel = self.request.get("tel")
         hp = self.request.get("hp")
         email = self.request.get("email")
         bal_amt = self.request.get("balAmt")
 
         #save data to view model class
         vm = AgentViewModel()
         vm.code = code
         vm.name = name
         vm.pwd = pwd
         vm.address = address
         vm.tel = tel
         vm.hp = hp
         vm.email = email
         vm.bal_amt = bal_amt
         vm.active = True
             
         app_service = AgentAppService()
         app_service.create(vm)
         
         json_values['returnStatus'] = True
     except Exception, ex:
         json_values['returnStatus'] = False
         json_values['returnMessage'] = str(ex)
Exemplo n.º 10
0
 def post(self, code):
     json_values = {}
     
     try:
         name = self.request.get('name')
         address = self.request.get("address")
         tel = self.request.get("tel")
         hp = self.request.get("hp")
         email = self.request.get("email")
         last_modified = self.request.get('lastModified')
         
         current_user = self.current_user()
         
         vm = AgentViewModel()
         vm.code = code
         vm.name = name
         vm.address = address
         vm.tel = tel
         vm.hp = hp
         vm.email = email
         vm.active = True
         vm.last_modified = last_modified
         vm.user_code = current_user.code
         
         app_service = AgentAppService()
         app_service.update(vm)
     
         json_values['returnStatus'] = True
     except Exception, ex:
         json_values['returnStatus'] = False
         json_values['returnMessage'] = str(ex)
Exemplo n.º 11
0
 def post(self, code):
     json_values = {}
     
     try:
         name = self.request.get('name')
         address = self.request.get('address')
         tel = self.request.get('tel')
         hp = self.request.get('hp')
         email = self.request.get('email')
         last_modified = self.request.get('lastModified')
         
         agent = Agent.query(Agent.code==code).get()
         current_agent = self.current_agent()
         
         vm = AgentViewModel()
         vm.code = current_agent.code
         vm.name = name
         vm.address = address
         vm.tel = tel
         vm.hp = hp
         vm.email = email
         vm.account_type = agent.account_type
         vm.active = True
         vm.last_modified = last_modified
         
         app_service = AccountAppService()
         app_service.update(vm)
     
         json_values['returnStatus'] = True
     except Exception, ex:
         json_values['returnStatus'] = False
         json_values['returnMessage'] = str(ex)