예제 #1
0
        public ActionResult AddDepartment([DataSourceRequest] DataSourceRequest request, DepartmentModel departmentModel)
        {
            try
            {
                if (departmentModel != null)
                {
                    this.systemDepartmentService = new SystemDepartmentService();

                    var systemDepartment = DataTransfer.Transfer<System_Department>(departmentModel, typeof(DepartmentModel));
                    systemDepartment.CreateTime = DateTime.Now;

                    departmentModel.ID = this.systemDepartmentService.AddDepartment(systemDepartment);

                    if (departmentModel.ID > 0)
                    {
                        return this.Json(new[] { departmentModel }.ToDataSourceResult(request, this.ModelState));
                    }
                }
            }
            catch (Exception exception)
            {
                throw new Exception("添加部门时发生错误", exception);
            }

            return this.View();
        }
예제 #2
0
        public ActionResult ModifyDepartment([DataSourceRequest] DataSourceRequest request, DepartmentModel departmentModel)
        {
            if (departmentModel != null && this.ModelState.IsValid)
            {
                try
                {
                    this.systemDepartmentService = new SystemDepartmentService();

                    var backstageDepartment = DataTransfer.Transfer<System_Department>(
                        departmentModel,
                        typeof(DepartmentModel));

                    this.systemDepartmentService.ModifyDepartment(backstageDepartment);
                }
                catch (Exception exception)
                {
                    throw new Exception("删除部门时发生错误", exception);
                }
            }

            return this.Json(new[] { departmentModel }.ToDataSourceResult(request, this.ModelState));
        }