public IActionResult Index()
        {
            tblKullanicilar tblKullanicilar = _IKullanicilarService.GetById(StaticValues.LoginId);
            ModelUser       user            = new ModelUser();

            user.name       = tblKullanicilar.Isim;
            user.surname    = tblKullanicilar.Soyisim;
            user.listDuyuru = _ITblDuyuruService.GetAll().ToList();
            return(View(user));
        }
        public List <DuyurularDto> DuyuruList()
        {
            List <DuyurularDto> list = new List <DuyurularDto>();
            DuyurularDto        duyuru;
            List <TblDuyuru>    duyurulist = _ITblDuyuruService.GetAll().ToList();

            foreach (var tblDuyuru in duyurulist)
            {
                duyuru = new DuyurularDto();
                if ((_ItblPdfDuyuruService.GetById(tblDuyuru.Id) == null))
                {
                    duyuru.PdfUrl = null;
                }
                else
                {
                    duyuru.PdfUrl = _ItblPdfService.GetById(_ItblPdfDuyuruService.GetById(tblDuyuru.Id).PdfId).PdfUrl;
                }

                if (_ItblResimDuyuruService.GetById(tblDuyuru.Id) == null)
                {
                    duyuru.resimUrl = "images/duyuru.jpg";
                }
                else
                {
                    duyuru.resimUrl = _ItblResimService.GetById(_ItblResimDuyuruService.GetById(tblDuyuru.Id).ResimId).ResimUrl;
                }
                duyuru.aciklama = tblDuyuru.İcerik;
                duyuru.baslik   = tblDuyuru.Baslik;
                duyuru.id       = tblDuyuru.Id;
                duyuru.Date     = tblDuyuru.UploadTime;
                duyuru.aktif    = tblDuyuru.aktif;
                list.Add(duyuru);
            }

            return(list);
        }
Ejemplo n.º 3
0
        public IActionResult Index(ModelUser model)
        {
            tblKullanicilar tblKullanicilar = _ItblKullanicilarService.GetById(StaticValues.LoginId);
            ModelUser       user            = new ModelUser();

            user.name    = tblKullanicilar.Isim;
            user.surname = tblKullanicilar.Soyisim;
            List <TblDuyuru> duyurlar = _itbkDuyuruService.GetAll().ToList();

            string e = model.icerik.Replace(Environment.NewLine, "<br>");

            int temp = duyurlar.Count + 1;;


            _itbkDuyuruService.Add(new TblDuyuru()
            {
                Baslik     = model.baslik,
                Id         = duyurlar.Count + 1,
                UploadTime = DateTime.Now,
                İcerik     = e,
                aktif      = 0
            });

            if (model.resimUrl != null)
            {
                var fileName = _hostingEnvironment.WebRootPath + @"\Main\images\resimler\";
                model.resimUrl.CopyTo(new FileStream(fileName + (_itblResimService.GetAll().ToList().Count + 1) + ".jpg", FileMode.Create));
                string ResimUrl = "images/resimler/" + (_itblResimService.GetAll().ToList().Count + 1) + ".jpg";
                int    temp1    = _itblResimService.GetAll().ToList().Count + 1;
                _itblResimService.Add(new tblResim()
                {
                    Id       = _itblResimService.GetAll().ToList().Count + 1,
                    ResimUrl = ResimUrl
                });
                _itResimDuyuruService.Add(new tblResimDuyuru()
                {
                    DuyuruId = temp,
                    ResimId  = temp1
                });
            }


            if (model.dosyaUrl != null)
            {
                var fileName = _hostingEnvironment.WebRootPath + @"\Main\pdfs\";
                model.dosyaUrl.CopyTo(new FileStream(fileName + (_itblPdfService.GetAll().ToList().Count + 1) + ".pdf",
                                                     FileMode.Create));
                string pdfurl = "pdfs/" + (_itblPdfService.GetAll().ToList().Count + 1) + ".pdf";

                int temp1 = _itblPdfService.GetAll().ToList().Count + 1;
                _itblPdfService.Add(new tblPdf()
                {
                    Id     = _itblPdfService.GetAll().ToList().Count + 1,
                    PdfUrl = pdfurl
                });
                _itblpdfDuyuruService.Add(new tblPdfDuyuru()
                {
                    DuyuruId = temp,
                    PdfId    = temp1
                });
            }

            user.isSuccessfull = true;

            return(View(user));
        }