예제 #1
0
        /// <inheritdoc />
        public override Contribution Save()
        {
            if (!this.IsValid())
            {
                return(null);
            }

            var visibilities = ContributionVisibilities.GetItemVisibilities();

            var contribution = new Contribution
            {
                Id                   = this.Id,
                TypeName             = this.TypeName,
                Type                 = this.Type,
                Technology           = this.Technology.ToContributionTechnology(),
                StartDate            = this.StartDate,
                Title                = this.Title,
                Description          = this.Description,
                AnnualQuantity       = this.AnnualQuantity,
                SecondAnnualQuantity = this.SecondAnnualQuantity,
                AnnualReach          = this.AnnualReach,
                ReferenceUrl         = this.ReferenceUrl,
                Visibility           =
                    visibilities.FirstOrDefault(
                        x =>
                        x.Description.Equals(
                            this.VisibilityValue,
                            StringComparison.CurrentCultureIgnoreCase))
            };

            return(contribution);
        }
예제 #2
0
        /// <inheritdoc />
        public override void Populate(Contribution model)
        {
            var visibilities = ContributionVisibilities.GetItemVisibilities();

            if (model != null)
            {
                this.Id                   = model.Id;
                this.TypeName             = model.TypeName;
                this.Type                 = model.Type;
                this.Technology           = model.Technology.ToActivityTechnology();
                this.StartDate            = model.StartDate;
                this.Title                = model.Title;
                this.Description          = model.Description;
                this.AnnualQuantity       = model.AnnualQuantity;
                this.SecondAnnualQuantity = model.SecondAnnualQuantity;
                this.AnnualReach          = model.AnnualReach;
                this.ReferenceUrl         = model.ReferenceUrl;
                this.Visibility           = model.Visibility == null
                                      ? visibilities.FirstOrDefault()
                                      : visibilities.FirstOrDefault(x => x.Id.Equals(model.Visibility.Id));

                this.VisibilityValue = this.Visibility?.Description;

                this.AnnualQuantityValue       = model.AnnualQuantity == null ? string.Empty : model.AnnualQuantity.ToString();
                this.SecondAnnualQuantityValue = model.SecondAnnualQuantity == null
                                                     ? string.Empty
                                                     : model.SecondAnnualQuantity.ToString();
                this.AnnualReachValue = model.AnnualReach == null ? string.Empty : model.AnnualReach.ToString();
            }
            else
            {
                this.Id                   = 0;
                this.TypeName             = string.Empty;
                this.Type                 = null;
                this.Technology           = null;
                this.StartDate            = DateTime.UtcNow;
                this.Title                = string.Empty;
                this.Description          = string.Empty;
                this.AnnualQuantity       = null;
                this.SecondAnnualQuantity = null;
                this.AnnualReach          = null;
                this.ReferenceUrl         = string.Empty;
                this.Visibility           = visibilities.FirstOrDefault();
                this.VisibilityValue      = this.Visibility?.Description;

                this.AnnualQuantityValue       = string.Empty;
                this.SecondAnnualQuantityValue = string.Empty;
                this.AnnualReachValue          = string.Empty;
            }
        }
        public EditableContributionFlyoutViewModel(
            ApiClient client,
            IContributionAreaDataContainer areaContainer,
            IContributionTypeDataContainer typeContainer)
        {
            this.client = client;

            this.Areas =
                areaContainer.GetAllAreas()
                .SelectMany(awardContribution => awardContribution.Areas)
                .GroupBy(x => x.AwardName)
                .Select(g => g.First())
                .SelectMany(a => a.Items)
                .ToList();
            this.Types            = typeContainer.GetAllTypes();
            this.Visibilities     = ContributionVisibilities.GetItemVisibilities();
            this.VisibilityValues = this.Visibilities.Select(x => x.Description);
        }