private void pageData()
 {
     BLL.Page pg = new BLL.Page();
     pg.LoadAll();
     uiGridViewPages.DataSource = pg.DefaultView;
     uiGridViewPages.DataBind();
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            pageData();

            if (!Page.IsPostBack)
            {
                if (!string.IsNullOrEmpty(Request.QueryString["Pid"]))
                {
                    uiPanelCurrent.Visible = true;
                    uiGridViewPages.Visible = false;

                    BLL.Page addPage = new BLL.Page();
                    addPage.LoadByPrimaryKey(int.Parse(Request.QueryString["Pid"]));
                    txtPageTitle.Text = addPage.TitleAr;
                    FCKeditor1.Value = Server.HtmlDecode(addPage.ContentAr);

                    if (FileUploadPageImg.HasFile)
                    {
                        string path = "/admin/images/" + DateTime.Now.ToString("ddmmyyyyhhmmss") + FileUploadPageImg.FileName;

                        Bitmap upimg = (Bitmap)Bitmap.FromStream(FileUploadPageImg.PostedFile.InputStream);
                        upimg.Save(MapPath(path), System.Drawing.Imaging.ImageFormat.Png);
                        addPage.ImagePath = path;
                    }
                }
                else
                {
                    uiPanelCurrent.Visible = false;
                    uiGridViewPages.Visible = true;
                }
            }
        }
Exemple #3
0
        public async Task <IActionResult> Deactivate([FromBody] int[] ids)
        {
            var bpage = new BLL.Page(unitOfWork);

            await bpage.Deactivate(ids);

            return(Json("Success!"));
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         BLL.Page page = new BLL.Page();
         page.LoadByPrimaryKey(2);
         uiLiteralContent.Text = Server.HtmlDecode(page.ContentAr);
     }
 }
        protected void btnSaveContent_Click(object sender, EventArgs e)
        {
            BLL.Page pag = new BLL.Page();
            pag.LoadByPrimaryKey(int.Parse(Request.QueryString["Pid"]));
            pag.TitleAr = lblPageTitle.Text;
            pag.ContentAr = Server.HtmlEncode(FCKeditor1.Value);

            pag.Save();
            Response.Redirect("PageContent.aspx");
        }
Exemple #6
0
        //
        // GET: /Home/
        public ActionResult Index()
        {
            RoteValueHelper rvh = new RoteValueHelper();
            var index = rvh.GetInt("index", 1);

            var pageSize = 10;
            var startIndex = (index - 1) * pageSize;
            var pageBll = new BLL.Page();

            var pages = pageBll.GetPages(startIndex, 10);
            List<Photo.Web.Models.Page> list = null;
            if (pages != null)
            {
                var pageIds = pages.Select(o => o.id).AsEnumerable();
                var fileBll = new BLL.File();
                var files = fileBll.GetFileInfos(pageIds);
                var tagBll = new BLL.Tag();
                var tags = tagBll.GetPageTags(pageIds);
                if (files != null)
                {
                    var imgs = (from f in files
                                select new Photo.Web.Models.Img
                                {
                                    Id = f.id,
                                    Url = f.url,
                                    Path = f.path,
                                    PageId = f.PageId,
                                    Width = f.width,
                                    Height = f.height
                                }).ToList();
                    list = (from p in pages
                            select new Photo.Web.Models.Page
                            {
                                Id = p.id,
                                AddTime = p.add_time,
                                Title = p.title,
                                Description = p.description,
                                DefaultImg = imgs.FirstOrDefault(o => o.PageId == p.id),
                            }).ToList();

                    list.ForEach(p =>
                    {
                        p.Tags = (from t in tags
                                  where t.PageID == p.Id
                                  select new Web.Models.Tag
                                  {
                                      ID = t.id,
                                      Name = t.tag,
                                      Citations = t.citations
                                  }).ToList();
                    });
                }
            }
            return View(list);
        }
Exemple #7
0
        public async Task <IActionResult> Delete([FromBody] int[] ids)
        {
            var bpage = new BLL.Page(unitOfWork);

            // Delete photos
            var pagephotos = await new BLL.PagePhoto(unitOfWork).Get(ids);

            if (pagephotos.Count() > 0)
            {
                await new BLL.Photo(unitOfWork).Delete(pagephotos.Select(x => x.PhotoId).ToArray(), _environment);
            }

            await bpage.Delete(ids);

            return(Json("Success!"));
        }
Exemple #8
0
        public async Task <IActionResult> New([Bind(Prefix = "Item1")] EF.Page model, [Bind(Prefix = "Item2")] bool isactive, IFormFile file)
        {
            ViewData["Title"] = "Blog/New";

            try
            {
                model.CreatedBy = User.Identity.Name;

                var bpage = new BLL.Page(unitOfWork);

                // Add Page
                if (!isactive)
                {
                    model.DateInactive = DateTime.Now;
                }

                var id = await bpage.Add(model);

                // Add Photo
                IFormFile uploadedImage = file;
                if (uploadedImage != null && uploadedImage.ContentType.ToLower().StartsWith("image/"))
                {
                    var pid = await new BLL.Photo(unitOfWork).Add(_environment, file);

                    var pp = new EF.PagePhoto();
                    pp.PageId  = id;
                    pp.PhotoId = pid;
                    await new BLL.PagePhoto(unitOfWork).Add(pp);
                }

                return(Redirect("~/Admin/Page"));
            }
            catch (DbUpdateException ex)
            {
                ModelState.AddModelError(string.Empty, "Entry is causing conflict or already exist.");
                return(View(new Tuple <EF.Page, bool>(model, isactive)));
            }
        }
Exemple #9
0
        //
        // GET: /Page/
        public ActionResult Index()
        {
            RoteValueHelper rvh = new RoteValueHelper();
            var pageId = rvh.GetInt("pageId", 1);

            var pageBll = new BLL.Page();
            var tagBll = new BLL.Tag();
            var fileBll = new BLL.File();
            Models.Page page = null;
            try
            {
                var pageInfo = pageBll.GetPage(pageId);
                var tagInfos = tagBll.GetPageTags(pageId);
                var imgs = fileBll.GetFileInfos(pageId);

                page = new Models.Page
                {
                    Title = pageInfo.title,
                    AddTime = pageInfo.add_time
                };
                page.Tags = (from t in tagInfos
                             select new Models.Tag
                             {
                                 ID = t.id,
                                 Name = t.tag
                             }).ToList();
                page.Imgs = (from i in imgs
                             select new Models.Img
                             {
                                 Id = i.id,
                                 Path = i.path
                             }).ToList();
            }
            catch (Exception ex) { }
            return View(page);
        }