public IActionResult loginAccount([FromForm] LoginDTO loginDTO) { SessionUtil.addTokenToSession(this.HttpContext, loginDTO._id == null ? loginDTO._phone : loginDTO._id); StaffManager staffManager = new StaffManager(); String result = ""; StaffInformaitonDTO staffInformaiton = new StaffInformaitonDTO(); if (loginDTO._phone != null) { result = staffManager.verifyPasswordAndPhone(loginDTO._phone, loginDTO._password); staffInformaiton = staffManager.getStaffInformationByPhone(loginDTO._phone); } else if (loginDTO._id != null) { result = staffManager.verifyPasswordAndId(loginDTO._id, loginDTO._password); staffInformaiton = staffManager.getStaffInformationById(loginDTO._id); } else { result = ConstMessage.NOT_FOUND; } return(Ok(new JsonCreate() { message = result, data = staffInformaiton })); }
public StaffInformaitonDTO convertStaffToDto(STAFF staff) { StaffInformaitonDTO staffInformaiton = new StaffInformaitonDTO(); staffInformaiton._id = staff.STAFF_ID; staffInformaiton._name = staff.NAME; staffInformaiton._phone = staff.PHONE; staffInformaiton._position = staff.POSITION; return(staffInformaiton); }
public IActionResult updatePassword([FromForm] StaffInformaitonDTO staff) { StaffManager staffManager = new StaffManager(); bool isSuccess = staffManager.resetStaffPassword(staff._id, staff._password); JsonCreate jsonResult = new JsonCreate(); jsonResult.message = isSuccess ? ConstMessage.UPDATE_SUCCESS : ConstMessage.UPDATE_FAIL; jsonResult.data = isSuccess; return(Ok(jsonResult)); }
public IActionResult updateStaffInformation([FromForm] StaffInformaitonDTO newStaffInformaiton) { StaffManager staffManager = new StaffManager(); bool isSuccess = staffManager.resetStaffInformation(newStaffInformaiton._id, newStaffInformaiton._name, newStaffInformaiton._phone); JsonCreate jsonResult = new JsonCreate(); jsonResult.message = isSuccess ? ConstMessage.UPDATE_SUCCESS : ConstMessage.UPDATE_FAIL; StaffInformaitonDTO staffInformation = staffManager.getStaffInformationById(newStaffInformaiton._id); jsonResult.data = staffInformation; return(Ok(jsonResult)); }
public IActionResult getStaffInformation(String id) { JsonCreate jsonResult = new JsonCreate(); StaffManager staffManager = new StaffManager(); StaffInformaitonDTO staffInformation = staffManager.getStaffInformationById(id); if (staffInformation != null) { jsonResult.message = ConstMessage.GET_SUCCESS; jsonResult.data = staffInformation; return(Ok(jsonResult)); } else { jsonResult.message = ConstMessage.NOT_FOUND; return(NotFound(jsonResult)); } }