コード例 #1
0
        private static CostLineItem GetOrCreateCostLineItem(ProductionDetailsFormDefinitionModel form,
                                                            IEnumerable <CostLineItem> costLineItems, string name, Currency paymentCurrency)
        {
            var item = costLineItems.FirstOrDefault(c => c.Name == name);

            if (item == null)
            {
                item = new CostLineItem
                {
                    Name            = name,
                    LocalCurrencyId = paymentCurrency.Id
                };
                form.CostLineItemSections.ForEach(sectionTemplate =>
                {
                    var itemTemplate = sectionTemplate.Items.Find(i => i.Name == name);

                    if (itemTemplate != null)
                    {
                        item.TemplateSectionId = sectionTemplate.Id;
                    }
                });
            }
            return(item);
        }
コード例 #2
0
 private static string GetLocalCurrencyLookupKey(ProductionDetailsFormDefinitionModel form, CostLineItemSectionTemplateModel costSection, CostLineItemSectionTemplateItemModel item)
 {
     return($"{form.Name}.{costSection.Name}.{item.Name}.local");
 }
コード例 #3
0
        public static CostTemplateVersionModel CreateTemplateModel()
        {
            var productionDetailsCollection = new List <ProductionDetailsTemplateModel>();
            var templateModel = new CostTemplateVersionModel
            {
                ProductionDetails = productionDetailsCollection
            };

            var audioProduction = new ProductionDetailsFormDefinitionModel {
                ProductionType = Constants.ProductionType.FullProduction
            };
            var audioForms = new List <ProductionDetailsFormDefinitionModel> {
                audioProduction
            };
            var audio = new ProductionDetailsTemplateModel
            {
                Forms = audioForms,
                Type  = Constants.ContentType.Audio
            };

            var digitalProduction = new ProductionDetailsFormDefinitionModel {
                ProductionType = Constants.ProductionType.FullProduction
            };
            var digitalForms = new List <ProductionDetailsFormDefinitionModel> {
                digitalProduction
            };
            var digital = new ProductionDetailsTemplateModel
            {
                Forms = digitalForms,
                Type  = Constants.ContentType.Digital
            };

            var photographyProduction = new ProductionDetailsFormDefinitionModel {
                ProductionType = Constants.ProductionType.FullProduction
            };
            var photographyForms = new List <ProductionDetailsFormDefinitionModel> {
                photographyProduction
            };
            var photography = new ProductionDetailsTemplateModel
            {
                Forms = photographyForms,
                Type  = Constants.ContentType.Photography
            };

            var videoProduction = new ProductionDetailsFormDefinitionModel {
                ProductionType = Constants.ProductionType.FullProduction
            };
            var videoPostProduction = new ProductionDetailsFormDefinitionModel {
                ProductionType = Constants.ProductionType.PostProductionOnly
            };
            var videoCgi = new ProductionDetailsFormDefinitionModel {
                ProductionType = Constants.ProductionType.CgiAnimation
            };
            var videoForms = new List <ProductionDetailsFormDefinitionModel>
            {
                videoProduction,
                videoPostProduction,
                videoCgi
            };
            var video = new ProductionDetailsTemplateModel
            {
                Forms = videoForms,
                Type  = Constants.ContentType.Video
            };

            productionDetailsCollection.AddRange(new[] { audio, digital, photography, video });

            return(templateModel);
        }
コード例 #4
0
        public void Setup()
        {
            _target = new CostLineItemUpdater(_efContextMock.Object,
                                              _revisionServiceMock.Object,
                                              _templateServiceMock.Object,
                                              new CostSectionFinder(),
                                              _costExchangeRateServiceMock.Object);
            var cost = new Cost();
            var costStageRevision = new CostStageRevision()
            {
                CostLineItems = new List <CostLineItem> {
                    new CostLineItem {
                    }
                }
            };
            var costTemplateVersion = new CostTemplateVersion();
            var costTemplate        = new CostTemplate();
            var fieldDefinitions    = new CustomFormData();
            var usd  = new Currency();
            var euro = new Currency();
            var gbp  = new Currency();

            cost.Id = _costId;
            costStageRevision.Id = _costStageRevisionId;

            cost.LatestCostStageRevision   = costStageRevision;
            cost.LatestCostStageRevisionId = _costStageRevisionId;
            cost.CostTemplateVersion       = costTemplateVersion;
            cost.CostTemplateVersionId     = _costTemplateVersionId;

            costTemplateVersion.CostTemplate = costTemplate;
            costTemplateVersion.Id           = _costTemplateVersionId;

            costTemplate.FieldDefinitions = fieldDefinitions;

            euro.Code = "EUR";
            usd.Code  = "USD";
            gbp.Code  = "GBP";

            euro.Id = Guid.NewGuid();
            usd.Id  = _usdCurrencyId;
            gbp.Id  = _gbpCurrencyId;

            var costs = new List <Cost> {
                cost
            };

            _costStageRevisions = new List <CostStageRevision> {
                costStageRevision
            };
            var currencies = new List <Currency> {
                euro, usd, gbp
            };

            _efContextMock.MockAsyncQueryable(costs.AsQueryable(), c => c.Cost);
            _efContextMock.MockAsyncQueryable(_costStageRevisions.AsQueryable(), c => c.CostStageRevision);
            _efContextMock.MockAsyncQueryable(currencies.AsQueryable(), c => c.Currency);

            var stageDetails = new PgStageDetailsForm
            {
                ContentType = new core.Builders.DictionaryValue
                {
                    Id    = Guid.NewGuid(),
                    Key   = "Video",
                    Value = "Video"
                },
                CostType       = dataAccess.Entity.CostType.Production.ToString(),
                ProductionType = new core.Builders.DictionaryValue
                {
                    Id    = Guid.NewGuid(),
                    Key   = "Full Production",
                    Value = "Full Production"
                },
                Title = "Cost Title"
            };

            _revisionServiceMock.Setup(csr => csr.GetStageDetails <PgStageDetailsForm>(_costStageRevisionId)).ReturnsAsync(stageDetails);

            var costTemplateVersionModel   = new CostTemplateVersionModel();
            var productionDetailCollection = new List <ProductionDetailsTemplateModel>();
            var productionDetails          = new ProductionDetailsTemplateModel();

            _form = new ProductionDetailsFormDefinitionModel
            {
                Name           = FormName,
                Label          = "Full production",
                ProductionType = Constants.ProductionType.FullProduction
            };
            var section = new CostLineItemSectionTemplateModel();
            var item    = new CostLineItemSectionTemplateItemModel();

            section.Name = SectionName;
            item.Name    = ItemName;

            section.Items = new List <CostLineItemSectionTemplateItemModel> {
                item
            };
            _form.CostLineItemSections = new List <CostLineItemSectionTemplateModel> {
                section
            };
            productionDetails.Forms = new List <ProductionDetailsFormDefinitionModel> {
                _form
            };
            productionDetails.Type = "Video";

            productionDetailCollection.Add(productionDetails);
            costTemplateVersionModel.ProductionDetails = productionDetailCollection;
            _templateServiceMock.Setup(ts => ts.GetCostTemplateVersionModel(It.IsAny <Guid>())).ReturnsAsync(costTemplateVersionModel);

            _userIdentity = new UserIdentity
            {
                Id        = _userId,
                IpAddress = "127.0.0.1"
            };

            var expectedExchangeRates = new List <ExchangeRate>()
            {
                new ExchangeRate {
                    FromCurrency = _usdCurrencyId,
                    Rate         = 1
                },
            };

            _costExchangeRateServiceMock.Setup(cer => cer.GetExchangeRatesByDefaultCurrency(It.IsAny <Guid>()))
            .ReturnsAsync(expectedExchangeRates);
        }