Exemplo n.º 1
0
        /// <summary>
        /// 添加数据页面
        /// </summary>
        /// <returns></returns>
        public IActionResult Add()
        {
            var model = new AddDepartmentsModel {
                Time = DateTime.Now.Date
            };

            return(View(model));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Add(AddDepartmentsModel model)
        {
            var groupKey = Guid.NewGuid();

            model.Time = model.Time.Date;
            var departments = new List <Department>
            {
                new Department {
                    CapUpdated = CapUpdate.UnUpdate, GroupKey = groupKey, Organization = Organization.Ceo, Time = model.Time, EmployeeNumber = model.CeoNo
                },
                new Department {
                    CapUpdated = CapUpdate.UnUpdate, GroupKey = groupKey, Organization = Organization.InternalControl, Time = model.Time, EmployeeNumber = model.InternalControlNo
                },
                new Department {
                    CapUpdated = CapUpdate.UnUpdate, GroupKey = groupKey, Organization = Organization.StrategicInvestment, Time = model.Time, EmployeeNumber = model.StrategicInvestmentNo
                },
                new Department {
                    CapUpdated = CapUpdate.UnUpdate, GroupKey = groupKey, Organization = Organization.HumanResources, Time = model.Time, EmployeeNumber = model.HumanResourcesNo
                },
                new Department {
                    CapUpdated = CapUpdate.UnUpdate, GroupKey = groupKey, Organization = Organization.FinancialManagement, Time = model.Time, EmployeeNumber = model.FinancialManagementNo
                },
                new Department {
                    CapUpdated = CapUpdate.UnUpdate, GroupKey = groupKey, Organization = Organization.ProductDevelopment, Time = model.Time, EmployeeNumber = model.ProductDevelopmentNo
                },
                new Department {
                    CapUpdated = CapUpdate.UnUpdate, GroupKey = groupKey, Organization = Organization.SupplyChain, Time = model.Time, EmployeeNumber = model.SupplyChainNo
                },
                new Department {
                    CapUpdated = CapUpdate.UnUpdate, GroupKey = groupKey, Organization = Organization.UserCenter, Time = model.Time, EmployeeNumber = model.UserCenterNo
                },
                new Department {
                    CapUpdated = CapUpdate.UnUpdate, GroupKey = groupKey, Organization = Organization.ExternalContact, Time = model.Time, EmployeeNumber = model.ExternalContactrNo
                }
            };
            var command = new CreateDepartmentCommand {
                Departments = departments
            };
            await _mediatR.Send(command, new CancellationToken());

            return(RedirectToAction("Index"));
        }