Esempio n. 1
0
        static void CreateEmployeeBySProc()
        {
            IUserDTO userDTO = (IUserDTO)DTOFactory.Instance.Create(DTOType.UserDTO);

            userDTO.EmployeeDTO = (IEmployeeDTO)DTOFactory.Instance.Create(DTOType.EmployeeDTO);

            System.Console.WriteLine("First Name : ");
            userDTO.EmployeeDTO.FirstName = System.Console.ReadLine();

            System.Console.WriteLine("Last Name : ");
            userDTO.EmployeeDTO.LastName = System.Console.ReadLine();

            System.Console.WriteLine("Date of Joining : ");
            DateTime doj;

            DateTime.TryParse(System.Console.ReadLine(), out doj);
            userDTO.EmployeeDTO.DateOfJoining = doj;

            System.Console.WriteLine("Email : ");
            userDTO.EmployeeDTO.Email = System.Console.ReadLine();

            System.Console.WriteLine("Department Id : ");
            userDTO.EmployeeDTO.DepartmentId = Convert.ToInt32(System.Console.ReadLine());

            System.Console.WriteLine("Password : "******"IsAdmin : ");
            userDTO.IsAdmin = Convert.ToBoolean(System.Console.ReadLine());

            IUserFacade userFacade = (IUserFacade)FacadeFactory.Instance.Create(FacadeType.UserManagerFacade);
            OperationResult <IUserDTO> createEmployeeRetVal = userFacade.CreateEmployeeBySProc(userDTO);

            if (createEmployeeRetVal.IsValid())
            {
                System.Console.WriteLine("Inserted!!  Emp Id : {0}   User Id : {1}", createEmployeeRetVal.Data.EmployeeId, createEmployeeRetVal.Data.UserId);
            }
        }