Ejemplo n.º 1
0
        public Object Post(EmployeeResource employeeResource)
        {
            LogRequest();

            if (employeeResource == null) { return "Employee is required"; }
            if (employeeResource.Address == null) { return "Employee.Address is required"; }

            var employee = new Employee
            {
                FamilyName = SafeTrim(employeeResource.FamilyName),
                GivenName = SafeTrim(employeeResource.GivenName),
                DateOfBirth = employeeResource.DateOfBirth,
                Title = SafeTrim(employeeResource.Title),
                Address = SafeTrim(employeeResource.Address),
                Telephone = SafeTrim(employeeResource.Telephone),
                Mobile = SafeTrim(employeeResource.Mobile),
                Email = SafeTrim(employeeResource.Email),
                TaxFileNumber = SafeTrim(employeeResource.TaxFileNumber),
                CompanyName = SafeTrim(employeeResource.CompanyName),
                AustralianBusinessNumber = SafeTrim(employeeResource.AustralianBusinessNumber),
                BSBNumber = SafeTrim(employeeResource.BSBNumber),
                AccountNumber = SafeTrim(employeeResource.AccountNumber),
                BankName = SafeTrim(employeeResource.BankName),
                BankBranch = SafeTrim(employeeResource.BankBranch),
                AccountName = SafeTrim(employeeResource.AccountName),
                SuperFundName = SafeTrim(employeeResource.SuperFundName),
                MemberNumber = SafeTrim(employeeResource.MemberNumber),
                QantasFrequentFlyerNumber = SafeTrim(employeeResource.QantasFrequentFlyerNumber),
                VirginVelocityNumber = SafeTrim(employeeResource.VirginVelocityNumber),
                EmiratesSkywardsNumber = SafeTrim(employeeResource.EmiratesSkywardsNumber),
                OthersNumber = SafeTrim(employeeResource.OthersNumber)
            };
            _db.Employees.Add(employee);
            _db.SaveChanges();

            return employee;
        }
Ejemplo n.º 2
0
        public Object Put(EmployeeResource employeeResource)
        {
            LogRequest();

            if (employeeResource == null) { return "Employee is required"; }
            if (employeeResource.EmployeeId == null) { return "Employee.EmployeeId is required"; }

            int employeeId = employeeResource.EmployeeId.Value;
            var list = _db.Employees.Where(x => x.EmployeeId == employeeId).ToList();
            Employee employee = null;

            if (list.Any())
            {
                employee = list.First();
                employee.FamilyName = SafeTrim(employeeResource.FamilyName);
                employee.GivenName = SafeTrim(employeeResource.GivenName);
                employee.DateOfBirth = employeeResource.DateOfBirth;
                employee.Title = SafeTrim(employeeResource.Title);
                employee.Address = SafeTrim(employeeResource.Address);
                employee.Telephone = SafeTrim(employeeResource.Telephone);
                employee.Mobile = SafeTrim(employeeResource.Mobile);
                employee.Email = SafeTrim(employeeResource.Email);
                employee.TaxFileNumber = SafeTrim(employeeResource.TaxFileNumber);
                employee.CompanyName = SafeTrim(employeeResource.CompanyName);
                employee.AustralianBusinessNumber = SafeTrim(employeeResource.AustralianBusinessNumber);
                employee.BSBNumber = SafeTrim(employeeResource.BSBNumber);
                employee.AccountNumber = SafeTrim(employeeResource.AccountNumber);
                employee.BankName = SafeTrim(employeeResource.BankName);
                employee.BankBranch = SafeTrim(employeeResource.BankBranch);
                employee.AccountName = SafeTrim(employeeResource.AccountName);
                employee.SuperFundName = SafeTrim(employeeResource.SuperFundName);
                employee.MemberNumber = SafeTrim(employeeResource.MemberNumber);
                employee.QantasFrequentFlyerNumber = SafeTrim(employeeResource.QantasFrequentFlyerNumber);
                employee.VirginVelocityNumber = SafeTrim(employeeResource.VirginVelocityNumber);
                employee.EmiratesSkywardsNumber = SafeTrim(employeeResource.EmiratesSkywardsNumber);
                employee.OthersNumber = SafeTrim(employeeResource.OthersNumber);
                _db.SaveChanges();
            }

            return employee;
        }