Exemplo n.º 1
0
        private static Visit ImportModelToVisit(ImportModel model, int?year)
        {
            DateTime?toNullable(DateTime x) => (DateTime.MinValue == x) ? (DateTime?)null : x;

            Persistence.Entities.Period p2p(Period x)
            {
                return(new Persistence.Entities.Period()
                {
                    Start = toNullable(x.From), End = toNullable(x.To)
                });
            }

            int tryGetYear(String id)
            {
                const int lengthYear = 4;
                int       y          = year ?? DateTime.Now.Year;

                if (id.Length >= lengthYear)
                {
                    Int32.TryParse(id.Substring(0, 4), out y);
                }
                return(y);
            }

            return(new Visit()
            {
                ExternalReference = model.Id,
                Year = tryGetYear(model.Id),
                Street = model.Street,
                Zip = model.Zip,
                NumberOfChildren = model.NumberOfChildren,
                Desired = model.Desired.Select(p2p).ToList(),
                Unavailable = model.Unavailable.Select(p2p).ToList(),
            });
        }
Exemplo n.º 2
0
        /// <summary>
        /// Merges the consumable into this model
        /// </summary>
        /// <param name="model"></param>
        /// <param name="consumable"></param>
        public void Merge(ImportModel consumable)
        {
            if (Desired == null)
            {
                Desired = consumable.Desired;
            }
            if (Unavailable == null)
            {
                Unavailable = consumable.Unavailable;
            }

            if (consumable.Desired != null)
            {
                Desired.AddRange(consumable.Desired);
            }
            if (consumable.Unavailable != null)
            {
                Unavailable.AddRange(consumable.Unavailable);
            }
        }