Ejemplo n.º 1
0
        protected override DriverResult Editor(GamePart part, dynamic shapeHelper)
        {
            var viewModel = new GamePartVM();

            DateTime?tmpGameDate = _dateLocalization.ReadDateLocalized(part.GameDate);

            Mapper.Initialize(cfg => {
                cfg.CreateMap <GamePart, GamePartVM>().ForMember(dest => dest.GameDate, opt => opt.Ignore());
            });
            Mapper.Map <GamePart, GamePartVM>(part, viewModel);
            viewModel.GameDate = _dateLocalization.WriteDateLocalized(tmpGameDate, true);
            return(ContentShape("Parts_GamePart_Edit", () => shapeHelper.EditorTemplate(TemplateName: "Parts/GamePart_Edit", Model: viewModel, Prefix: Prefix)));
        }
        /// <summary>
        /// Defines the shapes required for the part's main view.
        /// </summary>
        /// <param name="part">The part.</param>
        /// <param name="displayType">The display type.</param>
        /// <param name="shapeHelper">The shape helper.</param>
        protected override DriverResult Display(ActivityPart part, string displayType, dynamic shapeHelper)
        {
            var partSettings = part.Settings.GetModel <ActivityPartSettings>();

            DateTime?         localDateTimeStart = _dataLocalization.ReadDateLocalized(part.DateTimeStart);
            DateTime?         localDateTimeEnd   = _dataLocalization.ReadDateLocalized(part.DateTimeEnd);
            DateTime?         localDateRepeatEnd = _dataLocalization.ReadDateLocalized(part.RepeatEndDate);
            ActivityViewModel activityVM         = new ActivityViewModel();

            Mapper.Initialize(cfg => {
                cfg.CreateMap <ActivityPart, ActivityViewModel>()
                .ForMember(dest => dest.DateStart, opt => opt.Ignore())
                .ForMember(dest => dest.DateEnd, opt => opt.Ignore())
                .ForMember(dest => dest.TimeStart, opt => opt.Ignore())
                .ForMember(dest => dest.TimeEnd, opt => opt.Ignore())
                .ForMember(dest => dest.RepeatEndDate, opt => opt.Ignore())
                .ForMember(dest => dest.Monday, opt => opt.Ignore())
                .ForMember(dest => dest.Tuesday, opt => opt.Ignore())
                .ForMember(dest => dest.Wednesday, opt => opt.Ignore())
                .ForMember(dest => dest.Thursday, opt => opt.Ignore())
                .ForMember(dest => dest.Friday, opt => opt.Ignore())
                .ForMember(dest => dest.Saturday, opt => opt.Ignore())
                .ForMember(dest => dest.Sunday, opt => opt.Ignore())
                .ForMember(dest => dest.RepeatByDayNumber, opt => opt.Ignore())
                .ForMember(dest => dest.Settings, opt => opt.Ignore());
            });

            Mapper.Map(part, activityVM);

            activityVM.DateStart     = _dataLocalization.WriteDateLocalized(localDateTimeStart);
            activityVM.DateEnd       = _dataLocalization.WriteDateLocalized(localDateTimeEnd);
            activityVM.TimeStart     = _dataLocalization.WriteTimeLocalized(localDateTimeStart);
            activityVM.TimeEnd       = _dataLocalization.WriteTimeLocalized(localDateTimeEnd);
            activityVM.RepeatEndDate = _dataLocalization.WriteDateLocalized(part.RepeatEndDate);
            activityVM.Settings      = partSettings;
            if (part.RepeatType == "W")
            {
                activityVM.Monday    = part.RepeatDetails.Contains(DayOfWeek.Monday.ToString());
                activityVM.Tuesday   = part.RepeatDetails.Contains(DayOfWeek.Tuesday.ToString());
                activityVM.Wednesday = part.RepeatDetails.Contains(DayOfWeek.Wednesday.ToString());
                activityVM.Thursday  = part.RepeatDetails.Contains(DayOfWeek.Thursday.ToString());
                activityVM.Friday    = part.RepeatDetails.Contains(DayOfWeek.Friday.ToString());
                activityVM.Saturday  = part.RepeatDetails.Contains(DayOfWeek.Saturday.ToString());
                activityVM.Sunday    = part.RepeatDetails.Contains(DayOfWeek.Sunday.ToString());
            }
            else
            {
                activityVM.Monday    = false;
                activityVM.Tuesday   = false;
                activityVM.Wednesday = false;
                activityVM.Thursday  = false;
                activityVM.Friday    = false;
                activityVM.Saturday  = false;
                activityVM.Sunday    = false;
            }

            if (part.RepeatType == "M")
            {
                activityVM.RepeatByDayNumber = part.RepeatDetails.Contains("DayNum");
            }
            else
            {
                activityVM.RepeatByDayNumber = true;
            }

            return(ContentShape("Parts_ActivityDisplay",
                                () => shapeHelper.EditorTemplate(
                                    TemplateName: "Parts/ActivityDisplay",
                                    Model: activityVM,
                                    Prefix: Prefix)));
        }