Example #1
0
        public IActionResult loginAccount([FromForm] LoginDTO loginDTO)
        {
            SessionUtil.addTokenToSession(this.HttpContext, loginDTO._id == null?loginDTO._phone:loginDTO._id);
            CustomerManager        customerManager     = new CustomerManager();
            String                 result              = "";
            CustomerInformationDTO customerInformation = new CustomerInformationDTO();

            if (loginDTO._phone != null)
            {
                result = customerManager.verifyPasswordAndPhone(loginDTO._phone, loginDTO._password);
                customerInformation = customerManager.getCustomerByPhone(loginDTO._phone);
            }
            else if (loginDTO._id != null)
            {
                result = customerManager.verifyPasswordAndId(loginDTO._id, loginDTO._password);
                customerInformation = customerManager.getCustomerById(loginDTO._id);
            }
            else
            {
                result = ConstMessage.NOT_FOUND;
            }
            return(Ok(new JsonCreate()
            {
                message = result, data = customerInformation
            }));
        }
Example #2
0
        public IActionResult updatePassword([FromForm] CustomerInformationDTO customer)
        {
            CustomerManager customerManager = new CustomerManager();
            bool            isSuccess       = customerManager.resetCustomerPassword(customer._id, customer._password);
            JsonCreate      jsonResult      = new JsonCreate();

            jsonResult.message = isSuccess ? ConstMessage.UPDATE_SUCCESS : ConstMessage.UPDATE_FAIL;
            jsonResult.data    = isSuccess;
            return(Ok(jsonResult));
        }
Example #3
0
        public IActionResult updateStaffInformation([FromForm] CustomerInformationDTO newCustomerInformaiton)
        {
            CustomerManager customerManager = new CustomerManager();
            bool            isSuccess       = customerManager.resetCustomerInformation(newCustomerInformaiton._id,
                                                                                       newCustomerInformaiton._name, newCustomerInformaiton._phone);
            JsonCreate jsonResult = new JsonCreate();

            jsonResult.message = isSuccess ? ConstMessage.UPDATE_SUCCESS : ConstMessage.UPDATE_FAIL;
            CustomerInformationDTO customerInformation = customerManager.getCustomerById(newCustomerInformaiton._id);

            jsonResult.data = customerInformation;
            return(Ok(jsonResult));
        }