示例#1
0
        // <summary>
        // Add / Update Service Item
        // </summary>
        public ServiceItem SaveServiceItem(ServiceItem serviceItem)
        {
            ServiceItem dbVersion = serviceItemRepository.Find(serviceItem.ServiceItemId);

            //Code Duplication Check
            if (serviceItemRepository.CodeDuplicationCheck(serviceItem))
            {
                throw new CaresException(Resources.Pricing.ServiceItem.ServiceItemCodeDuplicationError);
            }

            if (dbVersion != null)
            {
                UpdateServiceItemPropertie(serviceItem, dbVersion);
                serviceItemRepository.Update(dbVersion);
            }
            else
            {
                dbVersion = new ServiceItem();
                SetServiceItemProperties(serviceItem, dbVersion);
                serviceItemRepository.Add(dbVersion);
            }
            serviceItemRepository.SaveChanges();
            // To Load the proprties
            return(serviceItemRepository.LoadServiceItemWithDetail(dbVersion.ServiceItemId));
        }
示例#2
0
        public Task Handle(ServiceItemCreatedEvent @event)
        {
            Console.WriteLine("Handling ServiceItemCreatedEvent.");
            // save to ReadDB
            ServiceItem serviceItem = new ServiceItem(
                @event.SiteId,
                @event.Name,
                @event.Description,
                @event.DefaultTimeLength,
                @event.Price,
                @event.AllowOnlineScheduling,
                @event.ServiceCategoryId,
                @event.IndustryStandardCategoryId
                ); //_mapper.Map<LocationRM>(message);

            try
            {
                _serviceRepository.Add(serviceItem);
                _serviceRepository.SaveChanges();
                Console.WriteLine("ServiceItemCreatedEvent handled.");
                return(Task.CompletedTask);
            }catch (Exception e) {
                Console.WriteLine(e.Message);
                Console.WriteLine(e.InnerException.Message);
                throw e;
            }
        }
示例#3
0
        public async Task <ServiceItemViewModel> AddServiceItem(ServiceItemViewModel serviceItem)
        {
            var domainservice = new SchedulableCatalogItem(
                serviceItem.SiteId,
                serviceItem.Name,
                serviceItem.Description,
                serviceItem.DefaultTimeLength,
                serviceItem.Price,
                serviceItem.ServiceCategoryId,
                serviceItem.IndustryStandardCategoryId
                );

            _serviceItemRepository.Add(domainservice);

            var serviceItemCreatedEvent = new ServiceItemCreatedEvent(
                domainservice.SiteId,
                domainservice.Id,
                domainservice.Name,
                domainservice.Description,
                domainservice.DefaultTimeLength,
                domainservice.Price,
                domainservice.AllowOnlineScheduling,
                domainservice.ServiceCategoryId,
                domainservice.IndustryStandardCategoryId
                );

            await _businessIntegrationEventService.PublishThroughEventBusAsync(serviceItemCreatedEvent);

            //_session.Add<ServiceItem>(domainservice);
            //_session.Commit();

            serviceItem.Id = domainservice.Id;

            return(serviceItem);
        }