Пример #1
0
        public ActionResult Index(tbl_Duyuru d, HttpPostedFileBase file)
        {
            if (ModelState.IsValid)
            {
                if (file.ContentLength > 0 || file != null)
                {
                    var extention = Path.GetExtension(file.FileName);
                    if (extention == ".jpg" || extention == ".png")
                    {
                        var filename = Path.GetFileName(file.FileName);
                        var path     = Path.Combine(Server.MapPath("~/upload"), filename);
                        file.SaveAs(path);


                        uow.GetRepository <tbl_Duyuru>().Update(new tbl_Duyuru
                        {
                            Duyuru_Id = d.Duyuru_Id,
                            Link      = d.Link,
                            Mesaj     = d.Mesaj,
                            ResimURL  = filename
                        });

                        uow.SaveChanges();
                        return(View(d));

                        ViewBag.DuyuruGuncellendi = "Duyuru güncellendi.";
                    }
                }
            }

            return(View(d));
        }
        // GET: AnaSayfa
        public ActionResult Anasayfa(int page = 1, int pageSize = 12)
        {
            tbl_Duyuru popup   = GetPopup();
            var        urunler = uow.GetRepository <tbl_Urun>().GetAll().ToList();

            ViewBag.Duyuru = uow.GetRepository <tbl_Duyuru>().GetById(1);

            AnasayfaModelView anasayfamodel = new AnasayfaModelView
            {
                Duyuru  = null,
                Urunler = urunler
            };
            PagedList <tbl_Urun> personModel = new PagedList <tbl_Urun>(urunler, page, pageSize);

            return(View(personModel));
        }
        public tbl_Duyuru GetPopup()
        {
            tbl_Duyuru popup = (tbl_Duyuru)Session["popup"];

            if (popup == null)
            {
                popup            = new tbl_Duyuru();
                popup.Duyuru_Id  = 1;
                Session["popup"] = popup;
            }
            else
            {
                popup.Duyuru_Id++;
            }

            return(popup);
        }