Ejemplo n.º 1
0
        internal List <ServiceListItem> GetServiceListItems(int insuranceID)
        {
            var data = _context.InsuranceServices.AsQueryable();

            if (insuranceID > 0)
            {
                data = data.Where(x => x.InsuranceID == insuranceID);
            }
            var items = new List <ServiceListItem>();

            foreach (var d in data.ToList())
            {
                var item = new ServiceListItem();

                var service      = _context.Services.Find(d.ServiceID);
                var providerType = _context.ProviderTypes.Find(d.ProviderTypeID);

                item.ID               = d.ID;
                item.ServiceID        = d.ServiceID;
                item.ServiceCode      = service.Code;
                item.ServiceName      = service.Name;
                item.ProviderTypeID   = d.ProviderTypeID;
                item.ProviderTypeCode = providerType.Code;
                item.EffectiveDate    = d.EffectiveDate;
                item.DefectiveDate    = d.DefectiveDate;

                items.Add(item);
            }

            return(items);
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> UpdateserviceListItemAsync([FromBody] ServiceListItem serviceListItemToUpdate)
        {
            var ServiceListItem = await _serviceListContext.ServiceListItems.SingleOrDefaultAsync(i => i.Id == serviceListItemToUpdate.Id);

            if (ServiceListItem == null)
            {
                return(NotFound(new { Message = $"Item with id {serviceListItemToUpdate.Id} not found." }));
            }

            var oldPrice = ServiceListItem.Price;
            var raiseserviceListItemPriceChangedEvent = oldPrice != serviceListItemToUpdate.Price;

            // Update current serviceListItem
            ServiceListItem = serviceListItemToUpdate;
            _serviceListContext.ServiceListItems.Update(ServiceListItem);

            if (raiseserviceListItemPriceChangedEvent) // Save serviceListItem's data and publish integration event through the Event Bus if price has changed
            {
                //Create Integration Event to be published through the Event Bus
                var priceChangedEvent = new ServiceListPriceChangedIntegrationEvent(ServiceListItem.Id, serviceListItemToUpdate.Price, oldPrice);

                // Achieving atomicity between original Catalog database operation and the IntegrationEventLog thanks to a local transaction
                await _catalogIntegrationEventService.SaveEventAndServiceListContextChangesAsync(priceChangedEvent);

                // Publish through the Event Bus and mark the saved event as published
                await _catalogIntegrationEventService.PublishThroughEventBusAsync(priceChangedEvent);
            }
            else // Just save the updated serviceListItem because the serviceListItem's Price hasn't changed.
            {
                await _serviceListContext.SaveChangesAsync();
            }

            return(CreatedAtAction(nameof(ItemByIdAsync), new { id = serviceListItemToUpdate.Id }, null));
        }
Ejemplo n.º 3
0
        private bool IsClickableItem(ServiceListItem serviceItem)
        {
            if (serviceItem.IsService || !(serviceItem.Value is BluetoothGattCharacteristic))
            {
                return(false);
            }

            var properties = ((BluetoothGattCharacteristic)serviceItem.Value).Properties;

            return(_allowedProperties.Any(p => properties.HasFlag(p)));
        }
Ejemplo n.º 4
0
        public async Task <ActionResult> CreateserviceListItemAsync([FromBody] ServiceListItem serviceListItem)
        {
            var item = new ServiceListItem
            {
                Description = serviceListItem.Description,
                Name        = serviceListItem.Name,
                Price       = serviceListItem.Price
            };

            _serviceListContext.ServiceListItems.Add(item);
            await _serviceListContext.SaveChangesAsync();

            return(CreatedAtAction(nameof(ItemByIdAsync), new { id = item.Id }, null));
        }
Ejemplo n.º 5
0
        public async Task <ActionResult> CreateServiceListItemAsync([FromBody] ServiceListRequests model)
        {
            var item = new ServiceListItem
            {
                Description = model.Description,
                Name        = model.Name,
                Price       = model.Price
            };

            _unitOfWork.ServiceListRepository.Insert(item);
            await _unitOfWork.SaveAsync();

            return(CreatedAtAction(nameof(GetByIdAsync), new { id = item.Id }, null));
        }
Ejemplo n.º 6
0
        public async Task <ActionResult> UpdateserviceListItemAsync([FromBody] ServiceListItem serviceListItemToUpdate)
        {
            var serviceListItems = await _unitOfWork.ServiceListRepository.Get(i => i.Id == serviceListItemToUpdate.Id);

            var serviceListItem = serviceListItems.FirstOrDefault();

            if (serviceListItem == null)
            {
                return(NotFound(new { Message = $"Item with id {serviceListItemToUpdate.Id} not found." }));
            }

            serviceListItem = serviceListItemToUpdate;
            _unitOfWork.ServiceListRepository.Update(serviceListItem);

            await _unitOfWork.SaveAsync();

            return(CreatedAtAction(nameof(GetByIdAsync), new { id = serviceListItemToUpdate.Id }, null));
        }
Ejemplo n.º 7
0
        private ServiceListItem CreateServiceListItem(string[] column, string[] headers)
        {
            if (column.Count() != headers.Count())
            {
                throw new Exception($"column count '{column.Count()}' not the same as headers count'{headers.Count()}'");
            }

            string priceString = column[Array.IndexOf(headers, "price")].Trim('"').Trim();

            if (!Decimal.TryParse(priceString, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out Decimal price))
            {
                throw new Exception($"price={priceString}is not a valid decimal number");
            }

            var ServiceListItem = new ServiceListItem()
            {
                Description = column[Array.IndexOf(headers, "description")].Trim('"').Trim(),
                Name        = column[Array.IndexOf(headers, "name")].Trim('"').Trim(),
                Price       = price,
            };

            return(ServiceListItem);
        }
Ejemplo n.º 8
0
        private void cmbService_SelectedIndexChanged(object sender, EventArgs e)
        {
            ServiceListItem item = (ServiceListItem)cmbService.SelectedItem;

            _controller.SelectService(item.Service);
        }