コード例 #1
0
 /// <summary>
 /// Created 2017-03-22 by William Flood
 ///
 /// </summary>
 /// <param name="employeeInstance"></param>
 /// <returns></returns>
 public int CreateEmployee(Employee employeeInstance)
 {
     try
     {
         var rowsAffected = EmployeeAccessor.CreateEmployee(employeeInstance);
         return(rowsAffected);
     }
     catch
     {
         throw;
     }
 }
コード例 #2
0
        public void createEmployeeTest()
        {
            Trace.WriteLine("Create Employee Testing ***");

            var employee = new Employee();

            employee.FirstName           = "Michael";
            employee.LastName            = "Takrama";
            employee.OtherNames          = "Worlanyo";
            employee.PersonalPhoneNumber = "233245042433";
            employee.PersonalEmail       = "*****@*****.**";

            employee.CountryId = 45;

            employee.MaritalStatus = false;
            employee.Gender        = true;
            employee.DateOfBirth   = DateTime.Now;
            employee.Username      = "******";
            employee.PasswordHash  = "SCSYCCM";
            employee.PhoneNumber   = "2332222";
            employee.Email         = "*****@*****.**";
            employee.HireDate      = DateTime.Now;
            employee.SSNo          = "234"; //needs to be added in presentation
            employee.PicUrl        = "234"; //needs to be added in presentation

            //employee.DepartmentId = "EGDEPT"; //not used in user table
            employee.UserRolesId      = "DESENG";
            employee.ClearanceLevelId = 204;
            employee.isEmployed       = true;
            employee.AdditonalInfo    = "Additional Info";

            int userID = EmployeeAccessor.CreateEmployee(employee);

            Trace.WriteLine("New User ID from test = " + userID);

            int actual;

            if (userID > 1000)
            {
                actual = 1;
            }
            else
            {
                actual = 0;
            }


            int expected = 1;

            Assert.AreEqual(expected, actual);
        }
コード例 #3
0
        // Employee CRUD

        /// <summary>
        /// Create new Employee
        /// </summary>
        /// <param name="employee">Employee Object</param>
        /// <returns>Return Confirmation Result</returns>
        public bool CreateEmployee(Employee employee)
        {
            bool result = false;

            //Set Password
            var userEncode = new UserManager();

            employee.PasswordHash = userEncode.HashSHA256(employee.Username.ToUpper());

            //Set Hire Date - control must be created in presentation layer
            employee.HireDate = DateTime.Now;

            //Handle Empty SSN Issue
            employee.SSNo = employee.SSNo != null ? employee.SSNo : String.Empty;

            //Handle Empty Pic Url issue
            employee.PicUrl = employee.PicUrl != null ? employee.PicUrl : String.Empty;

            //User isBlocked :: False
            employee.isBlocked = false;

            //Write Employee and Get new UserId
            employee.UserId = EmployeeAccessor.CreateEmployee(employee);

            // Write Addresses if not null
            int count = 0;

            if (employee.Address != null)
            {
                foreach (var addressElement in employee.Address)
                {
                    count += EmployeeAccessor.CreateAddressByUserID(employee.UserId, addressElement);
                }

                if (employee.UserId != 0 && count == employee.Address.Count)
                {
                    result = true;
                }

                return(result);
            }

            // Check for write succcess if address is null
            if (employee.UserId != 0)
            {
                result = true;
            }

            return(result);
        }
コード例 #4
0
        public bool CreateEmployee(string firstName, string lastName, string phoneNum,
                                   string zip, string email)
        {
            var result = false;

            try
            {
                result = (1 == EmployeeAccessor.CreateEmployee(firstName, lastName, phoneNum, zip, email));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message + ex.StackTrace);
            }
            return(result);
        }