示例#1
0
            public Schedule Convert(ScheduleDTO source, Schedule destination, ResolutionContext context)
            {
                if (source == null)
                {
                    return(null);
                }

                try
                {
                    destination = destination ?? new Schedule();

                    destination.Id           = source.Id;
                    destination.LastModified = DateTimeResolver.Resolve(source.ModificationDate);
                    destination.CreationDate = DateTimeResolver.Resolve(source.CreationDate);
                    destination.Name         = source.Name;
                    destination.ActiveUntil  = source.ActiveUntil;
                    destination.ActiveFrom   = source.ActiveFrom;

                    foreach (var item in source.ActiveHours)
                    {
                        destination.AddTimeInterval(Mapper.Map <ScheduleEntryDTO, ScheduleEntry>(item));
                    }

                    foreach (var item in source.ActiveDays)
                    {
                        destination.AddDay(item);
                    }

                    return(destination);
                }
                catch (Exception)
                {
                    throw;
                }
            }
            public Banner Convert(AdminBannerDTO source, Banner destination, ResolutionContext context)
            {
                if (source == null)
                {
                    return(null);
                }

                destination = destination ?? new Banner();

                try
                {
                    destination.Id           = source.Id;
                    destination.LastModified = DateTimeResolver.Resolve(source.ModificationDate);
                    destination.CreationDate = DateTimeResolver.Resolve(source.CreationDate);
                    destination.Name         = source.Name;
                    destination.Description  = source.Description;

                    var lScheduleChecker = DomainServiceLocator.Resolve <IScheduleChecker>();

                    foreach (var item in source.ActiveIntervals)
                    {
                        destination.AddSchedule(lScheduleChecker, Mapper.Map <Schedule>(item));
                    }

                    foreach (var item in source.Texts)
                    {
                        destination.AddBannerItem(Mapper.Map <StaticText>(item));
                    }

                    foreach (var item in source.RssSources)
                    {
                        destination.AddSource(Mapper.Map <RssSource>(item));
                    }

                    return(destination);
                }
                catch (EntidadNulaException ex)
                {
                    //TODO como lo muestro acá
                    return(null);
                }
                catch (IntervaloFechaInvalidoException ex)
                {
                    //TODO como lo muestro acá
                    return(null);
                }
            }
示例#3
0
            public Campaign Convert(CampaignDTO source, Campaign destination, ResolutionContext context)
            {
                if (source == null)
                {
                    return(null);
                }

                try
                {
                    destination = destination ?? new Campaign();

                    destination.Id           = source.Id;
                    destination.LastModified = DateTimeResolver.Resolve(source.ModificationDate);
                    destination.CreationDate = DateTimeResolver.Resolve(source.CreationDate);
                    destination.Name         = source.Name;
                    destination.Description  = source.Description;

                    IScheduleChecker lScheduleChecker = DomainServiceLocator.Resolve <IScheduleChecker>();

                    foreach (var item in source.ActiveIntervals)
                    {
                        destination.AddSchedule(lScheduleChecker, Mapper.Map <Schedule>(item));
                    }

                    //foreach (var item in source.Slides)
                    //{
                    //    destination.AddSlide(
                    //        Mapper.Map<SlideDTO, Slide>(item)
                    //        );
                    //}

                    return(destination);
                }
                catch (Exception)
                {
                    throw;
                }
            }
示例#4
0
            public ScheduleEntry Convert(ScheduleEntryDTO source, ScheduleEntry destination, ResolutionContext context)
            {
                if (source == null)
                {
                    return(null);
                }

                try
                {
                    destination = destination ?? new ScheduleEntry();

                    destination.Id           = source.Id;
                    destination.LastModified = DateTimeResolver.Resolve(source.ModificationDate);
                    destination.CreationDate = DateTimeResolver.Resolve(source.CreationDate);
                    destination.End          = source.EndTime;
                    destination.Start        = source.StartTime;

                    return(destination);
                }
                catch (Exception)
                {
                    throw;
                }
            }