Ejemplo n.º 1
0
 public void Load_(int moduleId)
 {
     this.ModuleId = moduleId;
     //ImagesList.DataSource =  SlideShow_Image.Find(null, moduleId, null, null, null, null, null, SlideShow_Image.Columns.SortOrder, true);
     ImagesList.DataSource = SlideShowImage.GetByModuleId(moduleId, SlideShowImage.Columns.SortOrder, null);
     ImagesList.DataBind();
 }
Ejemplo n.º 2
0
        public virtual async Task <ActionResult> AddSlideShow(SlideShowViewModel slideShowModel)
        {
            if (!ModelState.IsValid)
            {
                slideShowModel.SlideShowImages = await _slideShowService.GetSlideShowImages();

                return(View(slideShowModel));
            }

            var slide = new SlideShowImage();

            _mappingEngine.Map(slideShowModel, slide);

            var otherSlideShows = new List <SlideShowImage>();

            _mappingEngine.Map <IList <SlideShowViewModel>, IList <SlideShowImage> >(slideShowModel.SlideShowImages,
                                                                                     otherSlideShows);

            if (slideShowModel.Id.HasValue)
            {
                _slideShowService.EditSlide(slide, otherSlideShows);
                TempData["message"] = "اسلاید مورد نظر با موفقیت ویرایش شد";
            }
            else
            {
                _slideShowService.AddSlide(slide, otherSlideShows);
                TempData["message"] = "اسلاید جدید با موفقیت در سیستم ثبت شد";
            }


            await _unitOfWork.SaveAllChangesAsync();

            return(RedirectToAction(MVC.SlideShow.Admin.ActionNames.Index));
        }
Ejemplo n.º 3
0
        public void EditSlide(SlideShowImage slideShow, IList <SlideShowImage> otherSlideShows)
        {
            _slideShowImages.Attach(slideShow);
            _unitOfWork.Entry(slideShow).State = EntityState.Modified;


            FixOrder(otherSlideShows);
        }
Ejemplo n.º 4
0
        public void DeleteSlide(int slideId)
        {
            var entity = new SlideShowImage()
            {
                Id = slideId
            };

            _unitOfWork.Entry(entity).State = EntityState.Deleted;
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                SlideShowModule module = SlideShowModule.GetByModuleId(this.ModuleId);
                //slider_container.CssClass = module.SlideShowClassName;

                SlideShowImageCollection images = SlideShowImage.GetByModuleId(this.ModuleId, "sortOrder", "desc");
                ImagesList.DataSource = images;
                ImagesList.DataBind();
            }
        }
        protected void Item_DataBound(object sender, ListViewItemEventArgs e)
        {
            if (e.Item.ItemType == ListViewItemType.DataItem)
            {
                if (e.Item.DataItem != null && e.Item.DataItem is SlideShowImage)
                {
                    SlideShowImage slideShowImage = (SlideShowImage)e.Item.DataItem;
                    Image image = e.Item.FindControl("image") as Image;
                    image.ImageUrl = Page.ResolveUrl(slideShowImage.GetFullPath());

                    HyperLink hyperlink = e.Item.FindControl("hyperlink") as HyperLink;
                    hyperlink.NavigateUrl = slideShowImage.LinkUrl;
                }
            }
        }
Ejemplo n.º 7
0
 public void AddSlide(SlideShowImage slideShow, IList <SlideShowImage> otherSlideShows)
 {
     _slideShowImages.Add(slideShow);
     FixOrder(otherSlideShows);
 }
Ejemplo n.º 8
0
        protected void ImagesList_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            int id = int.Parse(e.CommandArgument.ToString());


            switch (e.CommandName)
            {
            case "Delete":
                //SlideShow_Image image = SlideShow_Image.Get(id);
                SlideShowImage image = SlideShowImage.GetById(id);
                if (null != image)
                {
                    try
                    {
                        File.Delete(Server.MapPath(image.GetFullPath()));
                    }
                    catch (Exception)
                    {
                    }
                }

                SlideShowImage.Delete(id);
                Msg.ShowSuccess(string.Format("Deleted {0}.", image.ImageFileName));
                break;

            case "MoveUp":
                SlideShowImage.MoveUp(id);
                break;

            case "MoveDown":
                SlideShowImage.MoveDown(id);
                break;

            case "Save":
                SlideShowImage saveImage = SlideShowImage.GetById(id);
                TextBox        txt       = e.Item.FindControl("txtLink") as TextBox;

                if (null != saveImage && txt != null)
                {
                    saveImage.LinkUrl = txt.Text.Trim();

                    if (this.IsJQuerySlidingTextContentSlideShow)
                    {
                        TextBox txtContentName = e.Item.FindControl("txtContentName") as TextBox;

                        if (txtContentName != null)
                        {
                            saveImage.SlideTextContentName = txtContentName.Text;
                        }
                    }

                    saveImage.Save();
                }
                break;

            default:
                break;
            }

            this.Load_(this.ModuleId);
        }
Ejemplo n.º 9
0
        public static void SaveSlideShow(string[] imageArray, int slideShowId, string[] captionHeadingArray, string[] captionTextArray, string slideShowName)
        {
            HelperMethods.ActivityTracker.Track("Saved a Slideshow", (int)UserActionEnum.Updated);
            // Check if there are any images already in current slideshow
            if (currentSlideShowImages.Count != 0)
            {
                // Delete the old records
                foreach (var s in currentSlideShowImages)
                {
                    db.SlideShowImages.Remove(s);
                }
            }

            // Add the new records
            for (int i = 0; i < imageArray.Length; i++)
            {
                SlideShowImage newSlide = new SlideShowImage();
                newSlide.FileId            = Convert.ToInt32(imageArray[i]);
                newSlide.SlideShowPosition = i + 1;
                newSlide.SlideShowHeading  = captionHeadingArray[i];
                newSlide.SlideShowText     = captionTextArray[i];
                newSlide.SlideShowId       = slideShowId;
                db.SlideShowImages.Add(newSlide);
            }

            try
            {
                // Set the notification
                notificationMessage = "The " + slideShowName + " slideshow was successfully updated.";
                notificationStyle   = "text-success";
                notification        = true;

                slideId = slideShowId;

                // Save
                db.SaveChanges();
            }
            catch (DataException dx)
            {
                // Set the notification
                notificationMessage = "The " + slideShowName + " slideshow could not be updated at this time. Please try again later or inform an Administrator.";
                notificationStyle   = "text-danger";
                notification        = true;

                slideId = slideShowId;

                // Write to log file
                LogFile.WriteToFile("SlideShowManager.aspx.cs", "SaveSlideShow", dx, "An Administrator tried to save a SlideShow.", "HPSErrorLog.txt");
            }
            catch (Exception ex)
            {
                // Set the notification
                notificationMessage = "The " + slideShowName + " slideshow could not be updated at this time. Please try again later or inform an Administrator.";
                notificationStyle   = "text-danger";
                notification        = true;

                slideId = slideShowId;

                // Write to log file
                LogFile.WriteToFile("SlideShowManager.aspx.cs", "SaveSlideShow", ex, "An Administrator tried to save a SlideShow.", "HPSErrorLog.txt");
            }
        }