Ejemplo n.º 1
0
        public static void MapToDB(ThisEntity from, DBEntity to)
        {
            to.Id = from.Id;

            if (to.Id == 0)
            {
                //make sure EntityId is not wiped out. Also can't actually chg
                if ((to.EntityId) == 0)
                {
                    to.EntityId = from.EntityId;
                }
            }

            to.ProfileName = from.ProfileName;
            to.Description = from.Description;

            if (IsValidDate(from.EndDate))
            {
                to.ExpirationDate = DateTime.Parse(from.EndDate);
            }
            else
            {
                to.ExpirationDate = null;
            }

            if (IsValidDate(from.StartDate))
            {
                to.DateEffective = DateTime.Parse(from.StartDate);
            }
            else
            {
                to.DateEffective = null;
            }

            to.DetailsUrl = from.CostDetails;

            to.CurrencyTypeId = null;
            if (from.CurrencyTypeId > 0)
            {
                to.CurrencyTypeId = from.CurrencyTypeId;
            }
            else if (!string.IsNullOrWhiteSpace(from.Currency))
            {
                Views.Codes_Currency currency = CodesManager.GetCurrencyItem(from.Currency);
                if (currency != null && currency.NumericCode > 0)
                {
                    to.CurrencyTypeId = currency.NumericCode;
                }
            }
        }
Ejemplo n.º 2
0
        public static void MapFromDB(DBEntity from, ThisEntity to, bool includingItems)
        {
            to.Id       = from.Id;
            to.RowId    = from.RowId;
            to.EntityId = from.EntityId;

            to.ProfileName = from.ProfileName;
            to.Description = from.Description;

            if (IsValidDate(from.ExpirationDate))
            {
                to.EndDate = (( DateTime )from.ExpirationDate).ToString("yyyy-MM-dd");
            }
            else
            {
                to.EndDate = "";
            }

            if (IsValidDate(from.DateEffective))
            {
                to.StartDate = (( DateTime )from.DateEffective).ToString("yyyy-MM-dd");
            }
            else
            {
                to.StartDate = "";
            }

            to.CostDetails = from.DetailsUrl;

            to.CurrencyTypeId = (int)(from.CurrencyTypeId ?? 0);
            Views.Codes_Currency code = CodesManager.GetCurrencyItem(to.CurrencyTypeId);
            if (code != null && code.NumericCode > 0)
            {
                to.Currency       = code.Currency;
                to.CurrencySymbol = code.HtmlCodes;
            }

            to.ProfileSummary = SetCostProfileSummary(to);
            if (IsValidDate(from.Created))
            {
                to.Created = ( DateTime )from.Created;
            }
            if (IsValidDate(from.LastUpdated))
            {
                to.LastUpdated = ( DateTime )from.LastUpdated;
            }

            to.Condition = Entity_ReferenceManager.GetAll(to.RowId, CodesManager.PROPERTY_CATEGORY_CONDITION_ITEM);

            if (includingItems)
            {
                //TODO - the items should be part of the EF record
                if (from.Entity_CostProfileItem != null && from.Entity_CostProfileItem.Count > 0)
                {
                    CostProfileItem row = new CostProfileItem();
                    foreach (EM.Entity_CostProfileItem item in from.Entity_CostProfileItem)
                    {
                        row = new CostProfileItem();
                        //TODO
                        CostProfileItemManager.MapFromDB(item, row, true);
                        to.Items.Add(row);
                    }
                }

                to.Jurisdiction = Entity_JurisdictionProfileManager.Jurisdiction_GetAll(to.RowId);
                to.Region       = Entity_JurisdictionProfileManager.Jurisdiction_GetAll(to.RowId, Entity_JurisdictionProfileManager.JURISDICTION_PURPOSE_RESIDENT);
            }
        }
Ejemplo n.º 3
0
        public static void MapFromDB(DBEntity input, ThisEntity output)
        {
            output.Id                     = input.Id;
            output.RowId                  = input.RowId;
            output.Name                   = input.Name == null ? "" : input.Name;
            output.Description            = input.Description == null ? "" : input.Description;
            output.DemographicInformation = input.DemographicInformation == null ? "" : input.DemographicInformation;
            if (IsValidDate(input.DateEffective))
            {
                output.DateEffective = (( DateTime )input.DateEffective).ToString("yyyy-MM-dd");
            }
            else
            {
                output.DateEffective = "";
            }
            //
            output.NumberAwarded     = (input.NumberAwarded ?? 0);
            output.LowEarnings       = (input.LowEarnings ?? 0);
            output.MedianEarnings    = (input.MedianEarnings ?? 0);
            output.HighEarnings      = (input.HighEarnings ?? 0);
            output.PostReceiptMonths = (input.PostReceiptMonths ?? 0);
            output.Source            = GetUrlData(input.Source);

            output.Currency = input.Currency;
            Views.Codes_Currency code = CodesManager.GetCurrencyItem(output.Currency);
            if (code != null && code.NumericCode > 0)
            {
                output.Currency       = code.Currency;
                output.CurrencySymbol = code.HtmlCodes;
            }

            if (IsValidDate(input.Created))
            {
                output.Created = ( DateTime )input.Created;
            }
            if (IsValidDate(input.LastUpdated))
            {
                output.LastUpdated = ( DateTime )input.LastUpdated;
            }

            if (!string.IsNullOrEmpty(input.JobsObtainedJson))
            {
                var jobsObtained = JsonConvert.DeserializeObject <List <QuantitativeValue> >(input.JobsObtainedJson);
                if (jobsObtained != null)
                {
                    output.JobsObtained = jobsObtained;
                }
            }

            //=====
            //var relatedEntity = EntityManager.GetEntity( output.RowId, false );
            //if ( relatedEntity != null && relatedEntity.Id > 0 )
            //	output.EntityLastUpdated = relatedEntity.LastUpdated;

            //components

            //
            output.Jurisdiction = Entity_JurisdictionProfileManager.Jurisdiction_GetAll(output.RowId);
            //get datasetprofiles
            output.RelevantDataSet = DataSetProfileManager.GetAll(output.RowId, true);

            //==========
        }         //