コード例 #1
0
        public Guid CreateStaff(CreateStaffRequestModel request, Guid createBy, Guid?id = null, DateTime?createDateTime = null,
                                DelFlagEnum delFlag = DelFlagEnum.Normal)
        {
            CreateStaffCommand command = request.MapTo <CreateStaffCommand>();

            command.Id         = id ?? Guid.NewGuid();
            command.CreateBy   = createBy;
            command.CreateDate = createDateTime ?? DateTime.Now;
            command.DelFlag    = (int)delFlag;
            _bus.SendCommand(command);
            return(command.Id);
        }
コード例 #2
0
        public void Insert()
        {
            //var handler = new CreateStaffHandler(new CreateStaffQuery(new ConnectionFactory(_configConnection)));

            var command = new CreateStaffCommand("first", "last", "123456789", "*****@*****.**", DateTime.Now, null,
                                                 "note");

            if (_commandHandler.Execute(command).Success)
            {
                Console.WriteLine("new record inserted.");
            }

            var staffQuery = new StaffQuery(new ConnectionFactory(_configConnection));
            var staffs     = staffQuery.GetStaffs();

            foreach (var staff in staffs)
            {
                Console.WriteLine($"Name: {staff.FirstName} {staff.LastName} Email: {staff.Email} Create: {staff.StartDate}");
            }
        }