Пример #1
0
        public static List <DucValueDto> MockPhotoGalleryValues()
        {
            List <DucValueDto> items = new List <DucValueDto>();

            DucValueDto ducValue1 = new DucValueDto();

            items.Add(ducValue1);
            ducValue1.DucId     = BlockRegister.PhotoGallery.Title;
            ducValue1.ValueText = "Gallery Title";

            DucValueDto ducValue2 = new DucValueDto();

            items.Add(ducValue2);
            ducValue2.DucId     = BlockRegister.PhotoGallery.Abstract;
            ducValue2.ValueText = "Gallery brief description";

            DucValueDto ducValue3 = new DucValueDto {
                DucId = BlockRegister.PhotoGallery.RelatedGalleryList
            };

            items.Add(ducValue3);
            ducValue3.ValueInt         = 1;
            ducValue3.AttachedSubjects = DucDataProvider.MockAttachedSubjects(4, "Gallery");


            return(items);
        }
Пример #2
0
        public static List <GridRowDto> MockPhotoGalleryPhotosGridRows(int rowCount)
        {
            List <GridRowDto> rows = new List <GridRowDto>();

            for (int index = 1; index <= rowCount; index++)
            {
                GridRowDto row = new GridRowDto();
                rows.Add(row);
                row.GridId = CmsRegister.PhotosGridId;
                List <DucValueDto> cells = new List <DucValueDto>();
                row.Cells = cells;

                DucValueDto valueTitle = new DucValueDto {
                    DucId = BlockRegister.PhotoGrid.Col_Title
                };
                cells.Add(valueTitle);
                valueTitle.ValueText = string.Format("Photo No.{0} Title", index);

                DucValueDto valueAbstract = new DucValueDto {
                    DucId = BlockRegister.PhotoGrid.Col_Abstract
                };
                cells.Add(valueAbstract);
                valueAbstract.ValueText = string.Format("Photo No.{0} abstract", index);

                DucValueDto valueImage = new DucValueDto {
                    DucId = BlockRegister.PhotoGrid.Col_Image
                };
                cells.Add(valueImage);
                valueImage.ValueUrl = "http://placehold.it/460x230";
            }

            return(rows);
        }
Пример #3
0
        public static List <GridRowDto> MockRecipeDetailInstructionGridRows(int rowCount)
        {
            List <GridRowDto> rows = new List <GridRowDto>();

            for (int index = 1; index <= rowCount; index++)
            {
                GridRowDto row = new GridRowDto();
                rows.Add(row);
                row.GridId = CmsRegister.InstructionGridId;
                List <DucValueDto> cells = new List <DucValueDto>();
                row.Cells = cells;

                DucValueDto valueOrder = new DucValueDto {
                    DucId = BlockRegister.RecipeInstructionGrid.Col_Sortorder, ValueInt = index
                };
                cells.Add(valueOrder);

                DucValueDto valueDescription = new DucValueDto {
                    DucId = BlockRegister.RecipeInstructionGrid.Col_Description
                };
                valueDescription.ValueText = string.Format("recipe instruction {0}, exact instructions on how to make this recipe exact instructions on how to make this recipe. exact instructions on how to make this recipe", index);
                cells.Add(valueDescription);
            }

            return(rows);
        }
Пример #4
0
        public static List <SubjectInfoDto> MockAttachedSubjectsOfVideo()
        {
            List <SubjectInfoDto> subjects = new List <SubjectInfoDto>();

            foreach (string videoId in VideoInstances.Keys)
            {
                SubjectInfoDto subject = new SubjectInfoDto();
                subjects.Add(subject);
                subject.Title       = string.Format("{0} Title", videoId);
                subject.Description = string.Format("{0} description, this is very interesting.", videoId);
                subject.UrlAlias    = string.Format("{0}", videoId).ToLower();
                // get imageUrl
                List <DucValueDto> values = VideoInstances[videoId];
                DucValueDto        value  = values.FirstOrDefault(o => object.Equals(o.DucId, BlockRegister.YouTubeVideoBlock.ThumbnailUrl));
                if (value != null)
                {
                    subject.ImageUrl = value.ValueText;
                }
                else
                {
                    subject.ImageUrl = "http://placehold.it/460x230";
                }
            }

            return(subjects);
        }
Пример #5
0
        public override void Populate(ReferenceInfoDto referenceInfo)
        {
            int  pageSize       = 0;
            bool showPagination = false;

            if (referenceInfo.ValuesDic.ContainsKey(BlockRegister.ListViewWidget.PageSize))
            {
                DucValueDto value = referenceInfo.ValuesDic[BlockRegister.ListViewWidget.PageSize];
                if (value.ValueInt.HasValue)
                {
                    pageSize = value.ValueInt.Value;
                }
                showPagination = pageSize > 0;
            }
            if (pageSize == 0)
            {
                pageSize = WebContext.Current.MaxPageSize;
            }

            int currentPage = PageIndex.HasValue && showPagination ? PageIndex.Value : 1;

            object            languageId = CurrentLanguage != null ? CurrentLanguage.Id : null;
            IReferenceService service    = ServiceLocator.Current.GetInstance <IReferenceService>();

            Items = service.GetAttachedSubjects(referenceInfo.ReferenceId,
                                                BlockRegister.ListViewWidget.ReferenceList,
                                                currentPage, pageSize, languageId);
            int totalCount = Items.Any() ? Items.First <SubjectInfoDto>().TotalCount : 0;

            PaginationViewModel           = new PaginationViewModel(totalCount, currentPage, pageSize, WebContext.Current.PagerWindowSize);
            PaginationViewModel.ShowTotal = false;
        }
Пример #6
0
        public static List <GridRowDto> MockRecipeDetailIngredientGridRows(int rowCount)
        {
            List <GridRowDto> rows = new List <GridRowDto>();

            for (int index = 1; index <= rowCount; index++)
            {
                GridRowDto row = new GridRowDto();
                rows.Add(row);
                row.GridId = CmsRegister.IngredientGridId;
                List <DucValueDto> cells = new List <DucValueDto>();
                row.Cells = cells;

                DucValueDto valueOrder = new DucValueDto {
                    DucId = BlockRegister.RecipeIngredientGrid.Col_Sortorder, ValueInt = index
                };
                cells.Add(valueOrder);

                DucValueDto valueIngredientName = new DucValueDto {
                    DucId = BlockRegister.RecipeIngredientGrid.Col_IngredientName, ValueText = string.Format("ingredient {0}, just samples", index)
                };
                cells.Add(valueIngredientName);

                DucValueDto valueQuantity = new DucValueDto {
                    DucId = BlockRegister.RecipeIngredientGrid.Col_Quantity, ValueText = index.ToString()
                };
                cells.Add(valueQuantity);

                DucValueDto valueUnitOfMeasure = new DucValueDto {
                    DucId = BlockRegister.RecipeIngredientGrid.Col_UnitOfMeasure, ValueText = "spoons"
                };
                cells.Add(valueUnitOfMeasure);
            }

            return(rows);
        }
Пример #7
0
        public static List <DucValueDto> MockYouTubeVideoValues(string videoId)
        {
            List <DucValueDto> items = new List <DucValueDto>();

            DucValueDto ducValue1 = new DucValueDto();

            items.Add(ducValue1);
            ducValue1.DucId     = BlockRegister.YouTubeVideoBlock.Title;
            ducValue1.ValueText = string.Format("Video {0} Title", videoId);

            DucValueDto ducValue2 = new DucValueDto();

            items.Add(ducValue2);
            ducValue2.DucId     = BlockRegister.YouTubeVideoBlock.Description;
            ducValue2.ValueText = string.Format("Video {0} brief description", videoId);

            DucValueDto ducValue3 = new DucValueDto {
                DucId = BlockRegister.YouTubeVideoBlock.VideoId
            };

            items.Add(ducValue3);
            ducValue3.ValueText = videoId;

            DucValueDto ducValue4 = new DucValueDto {
                DucId = BlockRegister.YouTubeVideoBlock.ThumbnailUrl
            };

            items.Add(ducValue4);
            ducValue4.ValueText = string.Format("http://img.youtube.com/vi/{0}/0.jpg", videoId);

            return(items);
        }
Пример #8
0
 public override void Populate(ReferenceInfoDto referenceInfo)
 {
     foreach (SubitemInfoDto subitem in BlockInfo.Subitems)
     {
         DucViewModel duc = new DucViewModel {
             DucId = subitem.SubitemId, DucType = subitem.DucType
         };
         Ducs.Add(duc);
         if (subitem.DucType != DucTypes.Grid)
         {
             DucValueDto value = null;
             if (referenceInfo.ValuesDic.ContainsKey(subitem.SubitemId))
             {
                 value = referenceInfo.ValuesDic[subitem.SubitemId];
             }
             duc.DucValue = value;
         }
         else
         {
             if (subitem.Grid != null)
             {
                 GridViewModel grid = new GridViewModel();
                 grid.ReferenceId = referenceInfo.ReferenceId;
                 grid.Grid        = subitem.Grid;
                 grid.GridRows    = referenceInfo.GridRows.Where(o => object.Equals(o.GridId, subitem.Grid.Id)).OrderByDescending(o => o.Id);
                 duc.Grid         = grid;
             }
         }
     }
 }
Пример #9
0
 private bool ValidateValue(DucValueDto ducValue, DucTypes ducType)
 {
     return(ducValue.ValueInt.HasValue ||
            ducValue.ValueDate.HasValue ||
            ducValue.ValueText.TrimHasValue() ||
            ducValue.ValueHtml.TrimHasValue() ||
            ducValue.ValueUrl.TrimHasValue());
 }
Пример #10
0
        public static List <DucValueDto> MockRotatorValues()
        {
            List <DucValueDto> items = new List <DucValueDto>();

            DucValueDto ducValue1 = new DucValueDto();

            items.Add(ducValue1);
            ducValue1.DucId            = BlockRegister.Rotator.RotatorItemCollection;
            ducValue1.AttachedSubjects = MockAttachedSubjects(4, "Recipe");

            return(items);
        }
Пример #11
0
        public override void Populate(ReferenceInfoDto referenceInfo)
        {
            Title = GetValueText(referenceInfo, BlockRegister.FeaturedContent.Title);

            if (referenceInfo.ValuesDic.ContainsKey(BlockRegister.FeaturedContent.FeatureItemCollection))
            {
                DucValueDto value = referenceInfo.ValuesDic[BlockRegister.FeaturedContent.FeatureItemCollection];
                if (value.AttachedSubjects != null && value.AttachedSubjects.Count > 0)
                {
                    HasValue = true;
                    Items    = value.AttachedSubjects;
                }
            }
        }
Пример #12
0
        public override void Populate(ReferenceInfoDto referenceInfo)
        {
            if (referenceInfo.ValuesDic.ContainsKey(BlockRegister.Rotator.RotatorItemCollection))
            {
                DucValueDto value = referenceInfo.ValuesDic[BlockRegister.Rotator.RotatorItemCollection];
                RotatorUniqueId = string.Format("rotator{0}", value.Id);
                foreach (SubjectInfoDto dto in value.AttachedSubjects)
                {
                    RotatorItem item = new RotatorItem();
                    RotatorEntity.Items.Add(item);
                    item.Title     = dto.Title;
                    item.Abstract  = dto.Description;
                    item.TargetUrl = dto.UrlAlias;
                    item.ImageUrl  = dto.ImageUrl;
                }
            }

            //SubitemInfoDto subitem = Block.Subitems.SingleOrDefault(o => object.Equals(o.SubitemId, BlockRegister.Rotator.RotatorItemCollection));
            //object gridId = null;
            //if (subitem != null && subitem.Grid != null)
            //{
            //    gridId = subitem.Grid.Id;
            //}
            //if (Reference.GridRows != null)
            //{
            //    foreach (GridRowDto row in Reference.GridRows.Where(o => object.Equals(o.GridId, gridId)))
            //    {
            //        RotatorItem item = new RotatorItem();
            //        RotatorEntity.Items.Add(item);
            //        DucValueDto valueLink = row.Cells.SingleOrDefault(o => object.Equals(o.DucId, GridRegister.RotatorItemGrid.Col_Hyperlink));
            //        if (valueLink != null)
            //        {
            //            item.Title = valueLink.ValueText;
            //            item.TargetUrl = valueLink.ValueUrl;
            //        }
            //        DucValueDto valueAbstract = row.Cells.SingleOrDefault(o => object.Equals(o.DucId, GridRegister.RotatorItemGrid.Col_Abstract));
            //        if (valueAbstract != null)
            //        {
            //            item.Abstract = valueAbstract.ValueText;
            //        }
            //        DucValueDto valueImage = row.Cells.SingleOrDefault(o => object.Equals(o.DucId, GridRegister.RotatorItemGrid.Col_Image));
            //        if (valueImage != null)
            //        {
            //            item.ImageUrl = valueImage.ValueUrl;
            //        }
            //    }
            //}
            HasValue = RotatorEntity.Items != null && RotatorEntity.Items.Count > 0;
        }
Пример #13
0
        public static List <DucValueDto> MockRecipeDetailValues()
        {
            List <DucValueDto> items = new List <DucValueDto>();

            DucValueDto ducValue1 = new DucValueDto();

            items.Add(ducValue1);
            ducValue1.DucId     = BlockRegister.RecipeBlock.Name;
            ducValue1.ValueText = "Recipe name";

            DucValueDto ducValue2 = new DucValueDto();

            items.Add(ducValue2);
            ducValue2.DucId     = BlockRegister.RecipeBlock.Abstract;
            ducValue2.ValueText = "Recipe abstract Recipe abstract Recipe abstract Recipe abstract Recipe abstract Recipe abstract";

            DucValueDto ducValue3 = new DucValueDto();

            items.Add(ducValue3);
            ducValue3.DucId     = BlockRegister.RecipeBlock.Image;
            ducValue3.ValueText = "Recipe image";
            ducValue3.ValueUrl  = "http://placehold.it/460x230";

            DucValueDto ducValue4 = new DucValueDto();

            items.Add(ducValue4);
            ducValue4.DucId    = BlockRegister.RecipeBlock.PrepareTime;
            ducValue4.ValueInt = 10;

            DucValueDto ducValue5 = new DucValueDto();

            items.Add(ducValue5);
            ducValue5.DucId    = BlockRegister.RecipeBlock.CookTime;
            ducValue5.ValueInt = 30;

            DucValueDto ducValue6 = new DucValueDto();

            items.Add(ducValue6);
            ducValue6.DucId    = BlockRegister.RecipeBlock.Servings;
            ducValue6.ValueInt = 3;

            //DucValueDto ducValue7 = new DucValueDto();
            //items.Add(ducValue7);
            //ducValue7.DucId = CmsRegister.RecipeBlock.Tips;
            //ducValue7.ValueHtml = "Recipe tips 123";

            return(items);
        }
Пример #14
0
        private string[] ConvertRow(GridDto grid, GridRowDto row)
        {
            List <string> values = new List <string>();

            values.Add(row.Id.ToString());
            foreach (GridColumnDto column in grid.Columns)
            {
                DucValueDto ducValue = row.Cells.SingleOrDefault(o => o.DucId.Equals(column.Id));
                if (ducValue != null)
                {
                    switch (column.ColumnType)
                    {
                    case DucTypes.SubTitle:
                    case DucTypes.Text:
                    case DucTypes.TextArea:
                        values.Add(ducValue.ValueText);
                        break;

                    case DucTypes.Html:
                    case DucTypes.HtmlArea:
                        values.Add(ducValue.ValueHtml);
                        break;

                    case DucTypes.Integer:
                        values.Add(ducValue.ValueInt.HasValue ? ducValue.ValueInt.Value.ToString() : string.Empty);
                        break;

                    case DucTypes.Image:
                        values.Add(ducValue.ValueUrl);
                        values.Add(ducValue.ValueText);
                        break;

                    case DucTypes.Hyperlink:
                        values.Add(ducValue.ValueUrl);
                        values.Add(ducValue.ValueText);
                        break;

                    case DucTypes.Datetime:
                        break;

                    default:
                        break;
                    }
                }
            }
            return(values.ToArray());
        }
Пример #15
0
        public override void Populate(ReferenceInfoDto referenceInfo)
        {
            if (referenceInfo.ValuesDic.ContainsKey(BlockRegister.PhotoList.Title))
            {
                Title = referenceInfo.ValuesDic[BlockRegister.PhotoList.Title].ValueText;
            }
            SubitemInfoDto subitem     = BlockInfo.Subitems.SingleOrDefault(o => object.Equals(o.SubitemId, BlockRegister.PhotoList.PhotosGrid));
            object         photoGridId = null;

            if (subitem != null && subitem.Grid != null)
            {
                photoGridId = subitem.Grid.Id;
            }
            if (referenceInfo.GridRows != null)
            {
                int index = 0;
                foreach (GridRowDto row in referenceInfo.GridRows.Where(o => object.Equals(o.GridId, photoGridId)))
                {
                    Photo item = new Photo();
                    Items.Add(item);
                    item.Index  = index++;
                    item.Credit = string.Empty;
                    DucValueDto valueTitle = row.Cells.SingleOrDefault(o => object.Equals(o.DucId, BlockRegister.PhotoGrid.Col_Title));
                    if (valueTitle != null)
                    {
                        item.Title = valueTitle.ValueText;
                    }
                    DucValueDto valueSubTitle = row.Cells.SingleOrDefault(o => object.Equals(o.DucId, BlockRegister.PhotoGrid.Col_Subtitle));
                    if (valueSubTitle != null)
                    {
                        item.Subtitle = valueSubTitle.ValueText;
                    }
                    DucValueDto valueAbstract = row.Cells.SingleOrDefault(o => object.Equals(o.DucId, BlockRegister.PhotoGrid.Col_Abstract));
                    if (valueAbstract != null)
                    {
                        item.Abstract = valueAbstract.ValueText;
                    }
                    DucValueDto valueImage = row.Cells.SingleOrDefault(o => object.Equals(o.DucId, BlockRegister.PhotoGrid.Col_Image));
                    if (valueImage != null)
                    {
                        item.ImageUrl = valueImage.ValueUrl;
                    }
                }
            }
        }
Пример #16
0
        public static List <DucValueDto> MockFeaturedContent2ndValues()
        {
            List <DucValueDto> items = new List <DucValueDto>();

            DucValueDto ducValue1 = new DucValueDto();

            items.Add(ducValue1);
            ducValue1.DucId     = BlockRegister.FeaturedContent2nd.Title;
            ducValue1.ValueText = "Latest Recipes";

            DucValueDto ducValue2 = new DucValueDto();

            items.Add(ducValue2);
            ducValue2.DucId            = BlockRegister.FeaturedContent2nd.FeatureItemCollection;
            ducValue2.AttachedSubjects = MockAttachedSubjects(6, "Recipe");

            return(items);
        }
Пример #17
0
        public static List <DucValueDto> MockListViewValues(string contentType)
        {
            List <DucValueDto> items = new List <DucValueDto>();

            DucValueDto ducValue1 = new DucValueDto();

            items.Add(ducValue1);
            ducValue1.DucId    = BlockRegister.ListViewWidget.PageSize;
            ducValue1.ValueInt = 10;

            DucValueDto ducValue2 = new DucValueDto();

            items.Add(ducValue2);
            ducValue2.DucId = BlockRegister.ListViewWidget.ReferenceList;
            //ducValue2.ValueInt = 0;
            //ducValue2.AttachedSubjects = MockAttachedSubjects(16, contentType);

            return(items);
        }
Пример #18
0
 public override void Populate(ReferenceInfoDto referenceInfo)
 {
     if (referenceInfo.ValuesDic.ContainsKey(BlockRegister.CastGroup.Title))
     {
         DucValueDto value = referenceInfo.ValuesDic[BlockRegister.CastGroup.Title];
         Title = value.ValueText;
     }
     if (referenceInfo.GridRows != null)
     {
         foreach (GridRowDto row in referenceInfo.GridRows)
         {
             Cast item = new Cast();
             Casts.Add(item);
             DucValueDto valueTitle = row.Cells.SingleOrDefault(o => object.Equals(o.DucId, BlockRegister.CastGrid.Col_MemberId));
             if (valueTitle != null)
             {
                 item.MemberId = valueTitle.ValueText;
             }
         }
     }
 }
Пример #19
0
        public static List <DucValueDto> MockBlogDetailValues()
        {
            List <DucValueDto> items = new List <DucValueDto>();

            DucValueDto ducValue1 = new DucValueDto();

            items.Add(ducValue1);
            ducValue1.DucId     = BlockRegister.BlogDetail.Title;
            ducValue1.ValueText = "Test Blog Title";

            DucValueDto ducValue2 = new DucValueDto();

            items.Add(ducValue2);
            ducValue2.DucId     = BlockRegister.BlogDetail.Author;
            ducValue2.ValueText = "Dave Test";

            DucValueDto ducValue3 = new DucValueDto();

            items.Add(ducValue3);
            ducValue3.DucId     = BlockRegister.BlogDetail.IssuedTime;
            ducValue3.ValueDate = DateTime.Today;

            DucValueDto ducValue4 = new DucValueDto {
                DucId = BlockRegister.BlogDetail.Image
            };

            items.Add(ducValue4);
            ducValue4.ValueUrl = "http://placehold.it/460x230";

            DucValueDto ducValue5 = new DucValueDto {
                DucId = BlockRegister.BlogDetail.Content
            };

            items.Add(ducValue5);
            ducValue5.ValueHtml = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam pulvinar metus et urna tempus interdum. Vestibulum purus neque, blandit non sollicitudin vitae, molestie in nisi. Cras in blandit erat. Pellentesque et dolor ut libero ultrices vulputate. Donec at velit ligula. Nunc nec tincidunt est, sit amet tincidunt sapien. Donec condimentum leo tristique sapien suscipit venenatis. Aenean dapibus condimentum porttitor. Mauris vulputate leo sit amet enim posuere, eu egestas ante pulvinar. Pellentesque sit amet arcu quis justo placerat vestibulum eu non odio. In vulputate ipsum sem, eu molestie ligula ultrices sit amet. Praesent pellentesque diam at ex hendrerit, non sagittis ligula consectetur. Suspendisse id turpis velit. Nunc hendrerit dolor neque, ac facilisis urna auctor a. Nunc sodales semper tellus vel lobortis. Nunc eget enim at nunc accumsan suscipit vel a nunc. Sed iaculis placerat ante, in lacinia dui lacinia nec. Duis malesuada luctus pellentesque. Vestibulum eros nisl, posuere vel molestie eu, consectetur quis nibh. Nunc at eleifend quam. Vestibulum urna neque, sodales non posuere vel, tristique eget risus. Integer blandit, orci ac ultricies efficitur, enim libero ultricies arcu, ut viverra metus massa ut massa. Sed ut mauris ac orci faucibus dignissim. Morbi laoreet id felis non gravida. Vivamus bibendum, nulla vitae luctus pellentesque, justo ligula maximus erat, non tempor mauris arcu quis ex. Cras viverra et quam sit amet efficitur. Ut pulvinar volutpat enim ac mattis. Vivamus at dolor lacus. Sed tincidunt arcu at nibh ornare sollicitudin. Morbi blandit vulputate lectus quis vestibulum. Vivamus vel velit dapibus, efficitur libero eget, commodo leo. Nulla facilisi. Nulla mollis et elit sit amet sodales. Nam fermentum maximus odio nec consequat. Nulla ut feugiat ex. Mauris vitae sollicitudin neque. Proin sagittis sapien eu mattis pretium. Pellentesque maximus enim a diam semper vulputate. Nam cursus suscipit purus, at egestas enim pellentesque pulvinar. Cras non dolor ex. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Integer blandit massa non fringilla auctor.";

            return(items);
        }
Пример #20
0
        public override void Populate(ReferenceInfoDto referenceInfo)
        {
            if (referenceInfo.ValuesDic.ContainsKey(BlockRegister.PhotoGallery.Title))
            {
                Gallery.Title = referenceInfo.ValuesDic[BlockRegister.PhotoGallery.Title].ValueText;
            }
            if (referenceInfo.ValuesDic.ContainsKey(BlockRegister.PhotoGallery.Subtitle))
            {
                Gallery.Subtitle = referenceInfo.ValuesDic[BlockRegister.PhotoGallery.Subtitle].ValueText;
            }
            if (referenceInfo.ValuesDic.ContainsKey(BlockRegister.PhotoGallery.Abstract))
            {
                Gallery.Abstract = referenceInfo.ValuesDic[BlockRegister.PhotoGallery.Abstract].ValueText;
            }
            if (referenceInfo.ValuesDic.ContainsKey(BlockRegister.PhotoGallery.ThumbnailUrl))
            {
                Gallery.ThumbnailUrl = referenceInfo.ValuesDic[BlockRegister.PhotoGallery.ThumbnailUrl].ValueUrl;
            }
            if (referenceInfo.ValuesDic.ContainsKey(BlockRegister.PhotoGallery.RelatedGalleryList))
            {
                DucValueDto value = referenceInfo.ValuesDic[BlockRegister.PhotoGallery.RelatedGalleryList];
                // Exclude current reference
                Gallery.RelatedGalleries = value.AttachedSubjects.Where(o => !object.Equals(o.ReferenceId, referenceInfo.ReferenceId)).ToList();
            }

            SubitemInfoDto subitem     = BlockInfo.Subitems.SingleOrDefault(o => object.Equals(o.SubitemId, BlockRegister.PhotoGallery.PhotosGrid));
            object         photoGridId = null;

            if (subitem != null && subitem.Grid != null)
            {
                photoGridId = subitem.Grid.Id;
            }
            if (referenceInfo.GridRows != null)
            {
                int index = 0;
                foreach (GridRowDto row in referenceInfo.GridRows.Where(o => object.Equals(o.GridId, photoGridId)))
                {
                    Photo item = new Photo();
                    Gallery.Items.Add(item);
                    item.Index  = index++;
                    item.Credit = string.Empty;
                    DucValueDto valueTitle = row.Cells.SingleOrDefault(o => object.Equals(o.DucId, BlockRegister.PhotoGrid.Col_Title));
                    if (valueTitle != null)
                    {
                        item.Title = valueTitle.ValueText;
                    }
                    DucValueDto valueSubTitle = row.Cells.SingleOrDefault(o => object.Equals(o.DucId, BlockRegister.PhotoGrid.Col_Subtitle));
                    if (valueSubTitle != null)
                    {
                        item.Subtitle = valueSubTitle.ValueText;
                    }
                    DucValueDto valueAbstract = row.Cells.SingleOrDefault(o => object.Equals(o.DucId, BlockRegister.PhotoGrid.Col_Abstract));
                    if (valueAbstract != null)
                    {
                        item.Abstract = valueAbstract.ValueText;
                    }
                    DucValueDto valueImage = row.Cells.SingleOrDefault(o => object.Equals(o.DucId, BlockRegister.PhotoGrid.Col_Image));
                    if (valueImage != null)
                    {
                        item.ImageUrl = valueImage.ValueUrl;
                    }
                }
            }

            HasValue = Gallery.Title.TrimHasValue() ||
                       Gallery.Abstract.TrimHasValue() ||
                       Gallery.ThumbnailUrl.TrimHasValue() ||
                       Gallery.Items.Count > 0;
        }
Пример #21
0
        public ActionResult EditContent(int id, FormCollection formData)
        {
            // Collect data from FormCollection
            ReferenceInfoDto reference = GetReference(id);

            if (ModelState.IsValid)
            {
                foreach (ZoneInfoDto zone in reference.Template.Zones)
                {
                    foreach (SubitemInfoDto item in zone.Block.Subitems)
                    {
                        if (item.DucType != DucTypes.Grid)
                        {
                            // Loop for each Subitem
                            DucValueDto subitemValue = null;
                            if (reference.ValuesDic.ContainsKey(item.SubitemId))
                            {
                                // Already has value for current Subitem
                                subitemValue = reference.ValuesDic[item.SubitemId];
                                CollectValues(subitemValue, formData, item.DucType, reference);
                            }
                            else
                            {
                                // No value for current Subitem, add new value
                                subitemValue       = new DucValueDto();
                                subitemValue.DucId = item.SubitemId;
                                CollectValues(subitemValue, formData, item.DucType, reference);
                                bool isValid = ValidateValue(subitemValue, item.DucType);
                                if (isValid)
                                {
                                    reference.ValuesDic.Add(item.SubitemId, subitemValue);
                                }
                            }
                        }
                    }
                }

                IFacadeUpdateResult <ReferenceData> result;
                if (CurrentLanguage.Id == WebContext.Current.DefaultLanguage.Id)
                {
                    result = Service.SaveReferenceValues(reference.ReferenceId, reference.ValuesDic);
                }
                else
                {
                    result = Service.SaveReferenceValues(reference.ValuesDic, CurrentLanguage.Id);
                }
                if (result.IsSuccessful)
                {
                    return(RedirectToAction(DetailAction, new { id = id }));
                }
                else
                {
                    ProcUpdateResult(result.ValidationResult, result.Exception);
                }
            }
            ReferenceEditViewModel model = new ReferenceEditViewModel(reference);

            model.FolderTree      = GetCurrentFolderTree(reference.FolderId);
            model.CurrentLanguage = CurrentLanguage;
            model.PageTitle       = string.Format("Page Content Edit: {0}", model.Instance.Name);
            return(View(model));
        }
Пример #22
0
        public override void Populate(ReferenceInfoDto referenceInfo)
        {
            if (referenceInfo.ValuesDic.ContainsKey(BlockRegister.RecipeBlock.Name))
            {
                Recipe.Name = referenceInfo.ValuesDic[BlockRegister.RecipeBlock.Name].ValueText;
            }
            if (referenceInfo.ValuesDic.ContainsKey(BlockRegister.RecipeBlock.Subtitle))
            {
                Recipe.Subtitle = referenceInfo.ValuesDic[BlockRegister.RecipeBlock.Subtitle].ValueText;
            }
            if (referenceInfo.ValuesDic.ContainsKey(BlockRegister.RecipeBlock.Image))
            {
                Recipe.ImageUrl  = referenceInfo.ValuesDic[BlockRegister.RecipeBlock.Image].ValueUrl;
                Recipe.ImageText = referenceInfo.ValuesDic[BlockRegister.RecipeBlock.Image].ValueText;
            }
            if (referenceInfo.ValuesDic.ContainsKey(BlockRegister.RecipeBlock.Abstract))
            {
                Recipe.Abstract = referenceInfo.ValuesDic[BlockRegister.RecipeBlock.Abstract].ValueText;
            }
            if (referenceInfo.ValuesDic.ContainsKey(BlockRegister.RecipeBlock.Tips))
            {
                Recipe.Tips = referenceInfo.ValuesDic[BlockRegister.RecipeBlock.Tips].ValueHtml;
            }
            if (referenceInfo.ValuesDic.ContainsKey(BlockRegister.RecipeBlock.PrepareTime))
            {
                Recipe.PrepareTimeMinutes = referenceInfo.ValuesDic[BlockRegister.RecipeBlock.PrepareTime].ValueInt;
            }
            if (referenceInfo.ValuesDic.ContainsKey(BlockRegister.RecipeBlock.CookTime))
            {
                Recipe.CookTimeMinutes = referenceInfo.ValuesDic[BlockRegister.RecipeBlock.CookTime].ValueInt;
            }
            if (referenceInfo.ValuesDic.ContainsKey(BlockRegister.RecipeBlock.Servings))
            {
                Recipe.Servings = referenceInfo.ValuesDic[BlockRegister.RecipeBlock.Servings].ValueInt;
            }
            SubitemInfoDto ingredientSubitem = BlockInfo.Subitems.SingleOrDefault(o => object.Equals(o.SubitemId, BlockRegister.RecipeBlock.IngredientGrid));
            object         ingredientGridId  = null;

            if (ingredientSubitem != null && ingredientSubitem.Grid != null)
            {
                ingredientGridId = ingredientSubitem.Grid.Id;
            }
            SubitemInfoDto instructionSubitem = BlockInfo.Subitems.SingleOrDefault(o => object.Equals(o.SubitemId, BlockRegister.RecipeBlock.InstructionGrid));
            object         instructionGridId  = null;

            if (instructionSubitem != null && instructionSubitem.Grid != null)
            {
                instructionGridId = instructionSubitem.Grid.Id;
            }

            if (referenceInfo.GridRows != null)
            {
                foreach (GridRowDto row in referenceInfo.GridRows.Where(o => object.Equals(o.GridId, ingredientGridId)))
                {
                    RecipeIngredient item = new RecipeIngredient();
                    Recipe.RecipeIngredients.Add(item);
                    DucValueDto valueOrder = row.Cells.SingleOrDefault(o => object.Equals(o.DucId, BlockRegister.RecipeIngredientGrid.Col_Sortorder));
                    if (valueOrder != null)
                    {
                        item.Sortorder = valueOrder.ValueInt.HasValue ? valueOrder.ValueInt.Value : 0;
                    }
                    DucValueDto valueIngredientName = row.Cells.SingleOrDefault(o => object.Equals(o.DucId, BlockRegister.RecipeIngredientGrid.Col_IngredientName));
                    if (valueIngredientName != null)
                    {
                        item.IngredientName = valueIngredientName.ValueText;
                    }
                    DucValueDto valueQuantity = row.Cells.SingleOrDefault(o => object.Equals(o.DucId, BlockRegister.RecipeIngredientGrid.Col_Quantity));
                    if (valueQuantity != null)
                    {
                        item.Quantity = valueQuantity.ValueText;
                    }
                    DucValueDto valueUnitOfMeasure = row.Cells.SingleOrDefault(o => object.Equals(o.DucId, BlockRegister.RecipeIngredientGrid.Col_UnitOfMeasure));
                    if (valueUnitOfMeasure != null)
                    {
                        item.UnitOfMeasure = valueUnitOfMeasure.ValueText;
                    }
                }
                foreach (GridRowDto row in referenceInfo.GridRows.Where(o => object.Equals(o.GridId, instructionGridId)))
                {
                    RecipeInstruction item = new RecipeInstruction();
                    Recipe.RecipeInstructions.Add(item);
                    DucValueDto valueOrder = row.Cells.SingleOrDefault(o => object.Equals(o.DucId, BlockRegister.RecipeInstructionGrid.Col_Sortorder));
                    if (valueOrder != null)
                    {
                        item.Sortorder = valueOrder.ValueInt.HasValue ? valueOrder.ValueInt.Value : 0;
                    }
                    DucValueDto valueDescription = row.Cells.SingleOrDefault(o => object.Equals(o.DucId, BlockRegister.RecipeInstructionGrid.Col_Description));
                    if (valueDescription != null)
                    {
                        item.Description = valueDescription.ValueText;
                    }
                }
            }
            // Keyword view model
            TagsViewModel           = new ReferenceKeywordsViewModel(referenceInfo);
            SocialShareBarViewModel = new SocialShareBarViewModel(RequestedUrl.AbsoluteUri, Recipe.Name, Recipe.ImageUrl);
        }
Пример #23
0
        private void CollectValues(DucValueDto ducValue, NameValueCollection formData, DucTypes ducType, ReferenceInfoDto reference)
        {
            switch (ducType)
            {
            case DucTypes.SubTitle:
            case DucTypes.Text:
            case DucTypes.TextArea:
                ducValue.ValueText = formData[DucHelper.GetClientId(ducValue.DucId)];
                break;

            case DucTypes.Html:
            case DucTypes.HtmlArea:
                ducValue.ValueHtml = formData[DucHelper.GetClientId(ducValue.DucId)];
                break;

            case DucTypes.Image:
                string fileId   = string.Format(UIConst.FileKeyFormatString, DucHelper.GetClientId(ducValue.DucId));
                string colTitle = string.Format(UIConst.ImageTitleKeyFormatString, DucHelper.GetClientId(ducValue.DucId));
                string title    = formData[colTitle];
                // Deal with image upload
                HttpPostedFileBase file = Request.Files[fileId];
                if (null != file && file.ContentLength > 0)
                {
                    // Save file and get result
                    FileSaveResult fileResult = FileHelper.SaveFile(title, file);
                    if (fileResult.IsSuccessful)
                    {
                        ducValue.ValueUrl  = fileResult.FileUri;
                        ducValue.ValueText = fileResult.Title;
                        // Save image as Document
                        DocumentDto document = new DocumentDto();
                        document.Title        = fileResult.Title;
                        document.ContentUri   = fileResult.FileUri;
                        document.OriginFile   = file.FileName;
                        document.OriginSource = "Reference";
                        document.IssuedDate   = DateTime.Now;
                        IDocumentService service = ServiceLocator.Current.GetInstance <IDocumentService>();
                        IFacadeUpdateResult <DocumentData> result = service.SaveDocument(document);
                    }
                    else
                    {
                    }
                }
                else
                {
                    string col1Name = string.Format(UIConst.ValueUrlKeyFormatString, DucHelper.GetClientId(ducValue.DucId));
                    string col2Name = string.Format(UIConst.ValueTextKeyFormatString, DucHelper.GetClientId(ducValue.DucId));
                    ducValue.ValueUrl  = formData[col1Name];
                    ducValue.ValueText = formData[col2Name];
                }
                break;

            case DucTypes.Integer:
                int valueInteger;
                if (int.TryParse(formData[DucHelper.GetClientId(ducValue.DucId)], out valueInteger))
                {
                    ducValue.ValueInt = valueInteger;
                }
                break;

            case DucTypes.Hyperlink:
                string col3Name = string.Format(UIConst.ValueUrlKeyFormatString, DucHelper.GetClientId(ducValue.DucId));
                string col4Name = string.Format(UIConst.ValueTextKeyFormatString, DucHelper.GetClientId(ducValue.DucId));
                ducValue.ValueUrl  = formData[col3Name];
                ducValue.ValueText = formData[col4Name];
                break;

            case DucTypes.Datetime:
                break;

            case DucTypes.ReferenceList:
                string col21Name = string.Format(UIConst.ValueIntKeyFormatString, DucHelper.GetClientId(ducValue.DucId));
                string col22Name = string.Format(UIConst.ValueTextKeyFormatString, DucHelper.GetClientId(ducValue.DucId));
                int    valueInt;
                if (int.TryParse(formData[col21Name], out valueInt))
                {
                    ducValue.ValueInt = valueInt;
                }
                ducValue.ValueText = formData[col22Name];
                break;

            case DucTypes.ReferenceCollection:
                string col5Name = string.Format(UIConst.ValueIntKeyFormatString, DucHelper.GetClientId(ducValue.DucId));
                int    value5Int;
                if (int.TryParse(formData[col5Name], out value5Int))
                {
                    ducValue.ValueInt = value5Int;
                }
                break;

            default:
                break;
            }
        }
Пример #24
0
        public ActionResult EditGridRow(int referenceId, int jqGridID)
        {
            ReferenceInfoDto  reference    = GetReference(referenceId);
            GridDto           grid         = GetGrid(reference, jqGridID);
            List <GridRowDto> gridRows     = reference.GridRows.Where(o => object.Equals(o.GridId, jqGridID)).ToList();
            JQGrid            gridInstance = new JQGrid();

            switch (gridInstance.AjaxCallBackMode)
            {
            case AjaxCallBackMode.EditRow:
                bool isValidEdit = ValidateInput();
                if (isValidEdit)
                {
                    int        rowId = Convert.ToInt32(Request.Form[BaseDto.FLD_Id]);
                    GridRowDto row   = gridRows.SingleOrDefault(r => r.Id.Equals(rowId));
                    foreach (GridColumnDto column in grid.Columns)
                    {
                        DucValueDto cell = row.Cells.SingleOrDefault(o => o.DucId.Equals(column.Id));
                        if (cell != null)
                        {
                            CollectValues(cell, Request.Form, column.ColumnType, reference);
                        }
                    }
                    IFacadeUpdateResult <GridRowData> result = Service.SaveGridRow(row);
                    if (result.IsSuccessful)
                    {
                        GridRowDto savedRow = result.ToDto(new GridRowConverter());
                        gridRows.Remove(row);
                        gridRows.Add(savedRow);
                    }
                }
                break;

            case AjaxCallBackMode.AddRow:
                bool isValid = ValidateInput();
                if (isValid)
                {
                    GridRowDto newRow = new GridRowDto();
                    newRow.ReferenceId = referenceId;
                    newRow.GridId      = jqGridID;
                    List <DucValueDto> cells = new List <DucValueDto>();
                    newRow.Cells = cells;
                    foreach (GridColumnDto column in grid.Columns)
                    {
                        DucValueDto cell = new DucValueDto();
                        cell.DucId = column.Id;
                        CollectValues(cell, Request.Form, column.ColumnType, reference);
                        cells.Add(cell);
                    }
                    IFacadeUpdateResult <GridRowData> result = Service.SaveGridRow(newRow);
                    if (result.IsSuccessful)
                    {
                        GridRowDto savedRow = result.ToDto(new GridRowConverter());
                        gridRows.Add(savedRow);
                    }
                }
                break;

            case AjaxCallBackMode.DeleteRow:
                int  deleteRowId        = Convert.ToInt32(Request.Form[BaseDto.FLD_Id]);
                bool isDeleteSuccessful = Service.DeleteGridRow(deleteRowId);
                gridRows.Remove(gridRows.SingleOrDefault(o => o.Id.Equals(deleteRowId)));
                break;
            }

            return(ConvertToJson(grid, gridRows));
        }