Exemplo n.º 1
0
        // <summary>
        // Delete Service Item by id
        // </summary>
        public void DeleteServiceItem(long serviceItemId)
        {
            ServiceItem dbversion = serviceItemRepository.Find((int)serviceItemId);

            ValidateBeforeDeletion(serviceItemId);
            if (dbversion == null)
            {
                throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture,
                                                                  "Service Item with Id {0} not found!", serviceItemId));
            }
            serviceItemRepository.Delete(dbversion);
            serviceItemRepository.SaveChanges();
        }
Exemplo n.º 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;
            }
        }