Exemplo n.º 1
0
        public async Task Put(string id, [FromBody] ClassificationCategory category)
        {
            var existingCategory = await _categoryService.GetById(id);

            MapValues(existingCategory, category);
            await _categoryService.Update(existingCategory);
        }
Exemplo n.º 2
0
        public async Task Update(ClassificationCategory category)
        {
            DocumentClient client = await _documentClientFactory.GetClient();

            category.ModifiedDate = DateTime.UtcNow;
            await client.ReplaceDocumentAsync(CreateDocumentUri(category), category);
        }
Exemplo n.º 3
0
        public async Task <ClassificationCategory> Post([FromBody] ClassificationCategory category)
        {
            var newCategory = _categoryService.CreateNew(new User {
                Id = "0e54b6da-caef-492f-bc95-b0669a8957d5"
            });

            MapValues(newCategory, category);
            await _categoryService.AddOrUpdate(newCategory);

            return(newCategory);
        }
        private Dto.Xsd.IncomeClassificationCategory MapIncomeClassificationCategory(ClassificationCategory classificationCategory)
        {
            switch (classificationCategory)
            {
            case ClassificationCategory.ProductSaleIncome:
                return(Dto.Xsd.IncomeClassificationCategory.ProductSaleIncome);

            case ClassificationCategory.ProvisionOfServicesIncome:
                return(Dto.Xsd.IncomeClassificationCategory.ProvisionOfServicesIncome);

            case ClassificationCategory.OtherIncomeAndProfits:
                return(Dto.Xsd.IncomeClassificationCategory.OtherIncomeAndProfits);

            case ClassificationCategory.OtherIncomeAdjustmentAndRegularisationEntries:
                return(Dto.Xsd.IncomeClassificationCategory.OtherIncomeAdjustmentAndRegularisationEntries);

            default:
                throw new ArgumentException($"Cannot map ClassificationCategory {classificationCategory} to {nameof(Dto.Xsd.IncomeClassificationCategory)}.");
            }
        }
Exemplo n.º 5
0
        private void MapValues(ClassificationCategory target, ClassificationCategory source)
        {
            target.Name = source.Name;
            target.ClassificationCategoryTypeId = source.ClassificationCategoryTypeId;
            target.RangeMax = source.RangeMax;
            target.RangeMin = source.RangeMin;

            target.Tags = target.Tags ?? new List <ClassificationTag>();


            // Remove tags that are not in source
            for (int i = target.Tags.Count - 1; i >= 0; i--)
            {
                var tag = target.Tags[i];
                if (!source.Tags.Where(t => t.Id == tag.Id).Any())
                {
                    target.Tags.RemoveAt(i);
                }
            }

            // Map Tags
            foreach (ClassificationTag sourceTag in source.Tags)
            {
                ClassificationTag targetTag = target.Tags.Where(t => !string.IsNullOrWhiteSpace(sourceTag.Id) && t.Id == sourceTag.Id).SingleOrDefault();

                if (targetTag == null)
                {
                    targetTag = _categoryService.CreateNewTag();
                    target.Tags.Add(targetTag);
                }
                else
                {
                    targetTag.ModifiedDate = DateTime.UtcNow;
                }

                targetTag.Name = sourceTag.Name;
            }

            target.Tags.Sort();
        }
Exemplo n.º 6
0
        public async Task AddOrUpdate(ClassificationCategory category)
        {
            DocumentClient client = await _documentClientFactory.GetClient();

            try
            {
                await client.ReadDocumentAsync(CreateDocumentUri(category));

                // If we successfully read then call update
                await Update(category);
            }
            catch (DocumentClientException dce)
            {
                if (dce.StatusCode == HttpStatusCode.NotFound)
                {
                    await client.CreateDocumentAsync(CreateDocumentCollectionUri(), category);
                }
                else
                {
                    throw;
                }
            }
        }
 public InvoiceRecordIncomeClassification(ClassificationType classificationType, ClassificationCategory classificationCategory, Amount amount)
 {
     ClassificationType     = classificationType;
     ClassificationCategory = classificationCategory;
     Amount = amount ?? throw new ArgumentNullException(nameof(Amount));
 }
 public NegativeRevenue(NegativeAmount netValue, TaxType taxType, NegativeAmount vatValue, ClassificationType classificationType, ClassificationCategory classificationCategory, PositiveInt lineNumber = null, VatExemptionType?vatExemption = null, CityTax cityTax = null)
     : base(netValue, taxType, vatValue, new[] { new ItemIncomeClassification(classificationType, classificationCategory, netValue) }, lineNumber, vatExemption, cityTax)
 {
 }
Exemplo n.º 9
0
 public ItemIncomeClassification(ClassificationType classificationType, ClassificationCategory classificationCategory, LimitedDecimal amount)
 {
     ClassificationType     = classificationType;
     ClassificationCategory = classificationCategory;
     Amount = amount ?? throw new ArgumentNullException(nameof(Amount));
 }
 private void ValidateSummaryDocumentResult(ClassificationCategory classification)
 {
     Assert.GreaterOrEqual(classification.ConfidenceScore, 0);
     Assert.LessOrEqual(classification.ConfidenceScore, 1);
     Assert.NotNull(classification.Category);
 }
Exemplo n.º 11
0
 // Private Methods
 private Uri CreateDocumentUri(ClassificationCategory category)
 {
     return(UriFactory.CreateDocumentUri(MusicService.DatabaseName, CollectionName, category.Id));
 }
Exemplo n.º 12
0
        public async Task Delete(ClassificationCategory category)
        {
            DocumentClient client = await _documentClientFactory.GetClient();

            await client.DeleteDocumentAsync(CreateDocumentUri(category));
        }