Exemplo n.º 1
0
        static void Main(string[] args)
        {
            //抽象工厂实现方式
            User userModel = new User {
                Name = "zhangsan"
            };
            IUser    user    = null;
            IFactory factory = new AccessFactory();

            user = factory.CreateUser();

            user.AddUser(userModel);

            //简单工厂实现方式
            DataAccess  dataAccess = new DataAccess();
            IDepartment department = dataAccess.CreateDepartment();

            department.AddDepartment(new Department()
            {
                Name = "hahah", Remark = "测试"
            });

            //简单工厂的switch 替换为反射

            IUser Iuser2 = dataAccess.CreateUser();

            Iuser2.GetSingleUser(userModel);

            IUser         iuser = null;
            SqlServerUser user3 = new SqlServerUser();

            iuser = (IUser)user3;

            Console.ReadKey();
        }
 public IActionResult Create(Department department)
 {
     if (ModelState.IsValid)
     {
         _department.AddDepartment(department);
         var Department = _department.GetAllDepartment().OrderBy(p => p.DepartmentName);
         return(View("Details", Department));
     }
     else
     {
         return(View());
     }
 }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            Console.OutputEncoding = Encoding.UTF8;
            IFactory factory = new AccessFactory();

            IUser user = factory.GetUserObj();

            IDepartment department = factory.GetDepartmentObj();

            user.AddUser(new User());

            user.GetUserById(1);

            department.AddDepartment(new Department());

            department.GetById(1);

            Console.ReadKey();
        }
Exemplo n.º 4
0
 public ReturnViewModel <Department> AddDepartment([FromBody] Department adepartment) => _department.AddDepartment(adepartment);
Exemplo n.º 5
0
 public IActionResult Create(Department department)
 {
     _department.AddDepartment(department);
     return(View());
 }