Beispiel #1
0
        public ServiceResponseMsg AddNewManualEmployee(Employee emp)
        {
            ServiceResponseMsg _seriviceResponseMsg = new ServiceResponseMsg();

            try {
                int numEmp = IsEmployeeExisted(emp.EmpNo);

                if (numEmp == 0)
                {
                    _employeeRepository.Add(emp);
                    _seriviceResponseMsg.status  = 1;
                    _seriviceResponseMsg.message = "Success to add new employee";
                    _seriviceResponseMsg.obj     = emp;
                }
                else if (numEmp > 0)
                {
                    _seriviceResponseMsg.status  = 2;
                    _seriviceResponseMsg.message = "This employee was existed";
                }
            } catch (SmartException e) {
                Debug.WriteLine(e.StackTrace);
                _seriviceResponseMsg.status  = 0;
                _seriviceResponseMsg.message = "Failed to add new employee";
            }

            return(_seriviceResponseMsg);
        }
Beispiel #2
0
        public ServiceResponseMsg UpdateManualEmployee(Employee emp)
        {
            ServiceResponseMsg _seriviceResponseMsg = new ServiceResponseMsg();


            try {
                _employeeRepository.Update(emp);
                _seriviceResponseMsg.status  = 1;
                _seriviceResponseMsg.message = "Success to update this employee";
                _seriviceResponseMsg.obj     = emp;
            } catch (SmartException e) {
                Debug.WriteLine(e.StackTrace);
                _seriviceResponseMsg.status  = 0;
                _seriviceResponseMsg.message = "Failed to update this employee";
            }

            return(_seriviceResponseMsg);
        }
Beispiel #3
0
        /* Record employee change log */
        private void RecordTransactionHistory(ServiceResponseMsg message)
        {
            var    _transactionHistoryRepository = new TransactionHistoryRepository();
            string jsonData = JsonConvert.SerializeObject(message);
            var    employee = (Employee)message.obj;

            var transactionHistory = new TransactionHistory()
            {
                ObjectType  = "EMPLOYEE",
                ObjectName  = "[HR].[EMPLOYEE]",
                ObjectId    = (employee != null) ? employee.Id : 0,
                JsonData    = jsonData,
                CreatedDate = DateTime.Now,
                CreatedBy   = RequestContext.Principal.Identity.Name
            };

            _transactionHistoryRepository.Add(transactionHistory);
            _transactionHistoryRepository.Commit();
        }