示例#1
0
        public Task Handle(ServiceCategoryCreatedEvent message)
        {
            Console.WriteLine("ServiceCategoryCreatedEvent handled.");
            // save to ReadDB
            ServiceCategory serviceCategory = new ServiceCategory(
                message.Id,
                message.Name,
                message.Description,
                message.AllowOnlineScheduling,
                message.ScheduleTypeValue,
                message.SiteId
                ); //_mapper.Map<LocationRM>(message);

            try
            {
                _serviceCategoryRepository.Add(serviceCategory);
                _serviceCategoryRepository.SaveChanges();
                return(Task.CompletedTask);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine(e.InnerException.Message);
                throw e;
            }
        }
示例#2
0
        public async Task <ServiceCategoryViewModel> AddServiceCategory(ServiceCategoryViewModel serviceCategory)
        {
            var domainServiceCategory = new ServiceCategory(
                serviceCategory.SiteId,
                serviceCategory.Name,
                serviceCategory.Description,
                serviceCategory.AllowOnlineScheduling,
                serviceCategory.ScheduleTypeId
                );

            _serviceCategoryRepository.Add(domainServiceCategory);

            //_session.Add<ServiceCategory>(domainServiceCategory);
            //_session.Commit();

            var serviceCategoryCreatedEvent = new ServiceCategoryCreatedEvent(
                domainServiceCategory.SiteId,
                domainServiceCategory.Id,
                domainServiceCategory.Name,
                domainServiceCategory.Description,
                domainServiceCategory.AllowOnlineScheduling,
                domainServiceCategory.ScheduleTypeId
                );

            await _businessIntegrationEventService.PublishThroughEventBusAsync(serviceCategoryCreatedEvent);

            serviceCategory.Id = domainServiceCategory.Id;

            return(serviceCategory);
        }