Пример #1
0
    def post(self):
        json_values = {}

        try:
            # get post data
            ic = self.request.get("customerIc")
            name = self.request.get("name")
            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")

            #save data to view model class
            vm = CustomerViewModel()
            vm.ic = ic
            vm.name = name
            vm.pwd = pwd
            vm.address = address
            vm.tel = tel
            vm.hp = hp
            vm.email = email
            vm.active = True

            app_service = CustomerAppService()
            app_service.create(vm)

            # return status
            json_values['returnStatus'] = True
        except Exception, ex:
            json_values['returnStatus'] = False
            json_values['returnMessage'] = str(ex)
Пример #2
0
 def post(self):
     json_values = {}
     
     try:
         ic = self.request.get('ic')
         pwd = self.request.get('pwd')
         
         if ic is None or len(ic) < 1:
             raise Exception('You must enter an IC/PP No.')
         
         if pwd is None or len(pwd) < 1:
             raise Exception('You must enter a Password.')
         
         vm = CustomerViewModel()
         vm.ic = ic
         vm.pwd = pwd
         
         app_service = AccountAppService()
         app_service.login(vm)
         
         # save to session
         self.session['customer_ic'] = vm.ic
         
         json_values['returnStatus'] = True
     except Exception, ex:
         json_values['returnStatus'] = False
         json_values['returnMessage'] = str(ex)
Пример #3
0
 def customer_login(self):
     try:
         vm = CustomerViewModel()
         vm.ic = '1'
         vm.pwd = '1'
         
         app_service = CustomerAccountAppService()
         app_service.login(vm)
         
         self.response.write("customer_login OK.")
     
     except Exception, ex:
         self.response.write("customer_login failed. %s" % str(ex))
Пример #4
0
    def customer_login(self):
        try:
            vm = CustomerViewModel()
            vm.ic = '1'
            vm.pwd = '1'

            app_service = CustomerAccountAppService()
            app_service.login(vm)

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

        except Exception, ex:
            self.response.write("customer_login failed. %s" % str(ex))
Пример #5
0
    def update_customer(self):
        try:
            data = Customer.query(ancestor=ndb.Key('Customer', '1')).get()

            vm = CustomerViewModel()
            vm.ic = '1'
            vm.name = '1'
            vm.address = 'a'
            vm.tel = '12'
            vm.hp = '13'
            vm.email = 'b'
            vm.last_modified = data.last_modified

            app_service = CustomerAppService()
            app_service.update(vm)

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

        except Exception, ex:
            self.response.write("update_customer failed. %s" % str(ex))
Пример #6
0
    def create_customer(self):
        try:
            vm = CustomerViewModel()
            vm.ic = '1'
            vm.name = '1'
            vm.address = '2'
            vm.tel = '3'
            vm.hp = '4'
            vm.email = '5'

            app_service = CustomerAppService()
            app_service.create(vm)

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

        except Exception, ex:
            self.response.write("create_customer failed. %s" % str(ex))
Пример #7
0
 def update_customer(self):
     try:
         data = Customer.query(ancestor=ndb.Key('Customer', '1')).get()
         
         vm = CustomerViewModel()
         vm.ic = '1'
         vm.name = '1'
         vm.address = 'a'
         vm.tel = '12'
         vm.hp = '13'
         vm.email = 'b'
         vm.last_modified = data.last_modified
         
         app_service = CustomerAppService()
         app_service.update(vm)
         
         self.response.write("update_customer OK.")
         
     except Exception, ex:
         self.response.write("update_customer failed. %s" % str(ex))
Пример #8
0
 def create_customer(self):
     try:
         vm = CustomerViewModel()
         vm.ic = '1'
         vm.name = '1'
         vm.address = '2'
         vm.tel = '3'
         vm.hp = '4'
         vm.email = '5'
         
         app_service = CustomerAppService()
         app_service.create(vm)
         
         self.response.write("create_customer OK.")
         
     except Exception, ex:
         self.response.write("create_customer failed. %s" % str(ex))
Пример #9
0
    def create(self, vm):
        # get agent
        agent_da = AgentDataAccess()
        agent = agent_da.get(vm.agent_code)
        if agent is None:
            raise Exception('Agent not found.')

        vm.agent = agent

        # save customer
        customer_vm = CustomerViewModel()
        customer_vm.ic = vm.customer_ic
        customer_vm.name = vm.customer_name
        customer_vm.address = vm.customer_address
        customer_vm.tel = vm.customer_tel
        customer_vm.hp = vm.customer_hp
        customer_vm.email = vm.customer_email

        customer_da = CustomerDataAccess()
        vm.customer = customer_da.save_register(customer_vm)

        self.__create(vm)
Пример #10
0
 def create(self, vm):
     # get agent
     agent_da = AgentDataAccess()
     agent = agent_da.get(vm.agent_code)
     if agent is None:
         raise Exception('Agent not found.')
     
     vm.agent = agent
     
     # save customer
     customer_vm = CustomerViewModel()
     customer_vm.ic = vm.customer_ic
     customer_vm.name = vm.customer_name
     customer_vm.address = vm.customer_address
     customer_vm.tel = vm.customer_tel
     customer_vm.hp = vm.customer_hp
     customer_vm.email = vm.customer_email
     
     customer_da = CustomerDataAccess()
     vm.customer = customer_da.save_register(customer_vm)
     
     self.__create(vm)
Пример #11
0
 def post(self):
     json_values = {}
     
     try:
         current_customer = self.current_customer()
         
         pwd = self.request.get('newPwd')
         old_pwd = self.request.get('oldPwd')
   
         vm = CustomerViewModel()
         vm.ic = current_customer.ic
         vm.code = vm.ic
         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)
Пример #12
0
    def post(self, ic):
        json_values = {}

        try:
            ic = self.request.get('ic')
            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 = CustomerViewModel()
            vm.name = name
            vm.ic = ic
            vm.code = vm.ic
            vm.address = address
            vm.tel = tel
            vm.hp = hp
            vm.email = email
            vm.active = True
            vm.comm_per = 5
            vm.last_modified = last_modified
            vm.user_code = current_user.code

            app_service = CustomerAppService()
            app_service.update(vm)

            json_values['returnStatus'] = True
        except Exception, ex:
            json_values['returnStatus'] = False
            json_values['returnMessage'] = str(ex)
Пример #13
0
    def post(self, ic):
        json_values = {}
        
        try:
            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')
            
            #customer = Customer.query(Customer.ic==ic).get()

            current_customer = self.current_customer()
            
            vm = CustomerViewModel()
            vm.name = current_customer.name
            vm.ic = current_customer.ic
            vm.code = vm.ic
            vm.address = address
            vm.tel = tel
            vm.hp = hp
            vm.email = email
            vm.active = True
            vm.comm_per = 5
            vm.last_modified = last_modified
            vm.user_code = current_customer.ic
            
            app_service = AccountAppService()
            app_service.update(vm)
        
            json_values['returnStatus'] = True
        except Exception, ex:
            json_values['returnStatus'] = False
            json_values['returnMessage'] = str(ex)