Exemple #1
0
        // public string
        public KonuResponse KonuGuncelle(KonuResponse konuResponse)
        {
            Konular konular = _konularRepository.Find(x => x.Id == konuResponse.Id);

            konular.Hakkinda = konuResponse.Hakkinda;
            konular.KonuAdi  = konuResponse.KonuAdi;
            konular.Slug     = _genelAppService.KarakterCevir(konuResponse.KonuAdi);
            if (konuResponse.Resim != "bos")
            {
                string imagePath = @"C:\Users\fatih\Desktop\BitirmeResim\Konu_Resim\" + konuResponse.Resim;
                string imge      = _genelAppService.GetBase64StringForImage(imagePath);
                byte[] img       = Convert.FromBase64String(imge);
                string resimad   = _genelAppService.GetImageResimResponse(konuResponse.KonuAdi) + ".jpg";
                System.IO.File.WriteAllBytes(@"wwwroot\Belgeler\Image\" + resimad, img);
                konular.Resim = resimad;
            }



            _konularRepository.Update(konular);

            KonuResponse konuResponse1 = new KonuResponse();

            return(_mapper.Map <KonuResponse>(konular));
        }
Exemple #2
0
        public BaseResponse KonuEkle(KonuResponse konuResponse)
        {
            //eğer böyle bir kategori adı zaten varsa bildirsin ve güncellemeyede ekle
            Konular konular = new Konular();

            konular.Hakkinda = konuResponse.Hakkinda;
            konular.KonuAdi  = konuResponse.KonuAdi;
            konular.Slug     = _genelAppService.KarakterCevir(konuResponse.KonuAdi);
            if (konuResponse.Resim == "bos")
            {
                // string imagePath = @"D:\Programlama\C#_Uygulamalari\PROJELERİM\Bitirme\Bitirme\Bitirme\Bitirme\wwwroot\Belgeler\Image\bos.png";
                //string imge = _genelAppService.GetBase64StringForImage(imagePath);
                //byte[] img = Convert.FromBase64String(imge);
                //string resimad = _genelAppService.GetImageResimResponse(konuResponse.KonuAdi) + ".jpg";
                //System.IO.File.WriteAllBytes(@"wwwroot\Belgeler\Image\" + resimad, img);
                konular.Resim = "bos.png";
            }
            else
            {
                string imagePath = @"C:\Users\fatih\Desktop\BitirmeResim\Konu_Resim\" + konuResponse.Resim;
                string imge      = _genelAppService.GetBase64StringForImage(imagePath);
                byte[] img       = Convert.FromBase64String(imge);
                string resimad   = _genelAppService.GetImageResimResponse(konuResponse.KonuAdi) + ".jpg";
                System.IO.File.WriteAllBytes(@"wwwroot\Belgeler\Image\" + resimad, img);
                konular.Resim = resimad;
            }

            _konularRepository.Insert(konular);
            //----
            //var files = HttpContext.Request.Form.Files;
            //foreach (var Image in files)
            //{
            //    if (Image != null && Image.Length > 0)
            //    {
            //        var file = Image;
            //        //There is an error hereD:\Programlama\C#_Uygulamalari\PROJELERİM\Bitirme\Bitirme\Bitirme\Bitirme\wwwroot\Belgeler\Image\20194302147871e.jpg
            //        var uploads = Path.Combine(_appEnvironment.WebRootPath, "D:\\Programlama\\C#_Uygulamalari\\PROJELERİM\\Bitirme\\Bitirme\\Bitirme\\Bitirme\\wwwroot\\Belgeler\\Image");
            //        if (file.Length > 0)
            //        {
            //            var fileName = Guid.NewGuid().ToString().Replace("-", "") + Path.GetExtension(file.FileName);
            //            using (var fileStream = new FileStream(Path.Combine(uploads, fileName), FileMode.Create))
            //            {
            //                file.CopyToAsync(fileStream);
            //                konular.Resim = fileName;
            //                _konularAppService.Insert(konular);
            //            }

            //        }
            //    }
            //}



            BaseResponse baseResponse = new BaseResponse();

            baseResponse.durum = true;
            baseResponse.mesaj = "Başarılı";
            return(baseResponse);
        }
Exemple #3
0
        public KonuResponse KonuDuzenle(KonuIdRequest konuIdRequest)
        {
            Konular      konular      = _konularRepository.Find(x => x.Id == konuIdRequest.Id);
            KonuResponse konuResponse = new KonuResponse();

            konuResponse.Hakkinda = konular.Hakkinda;
            konuResponse.Id       = konular.Id;
            konuResponse.KonuAdi  = konular.KonuAdi;
            konuResponse.Resim    = konular.Resim;
            return(konuResponse);
        }
        public ActionResult New(KonuNew formData)
        {
            if (!ModelState.IsValid)
            {
                return(View(formData));
            }

            var konu = new Konular()
            {
                Konu     = formData.Konu,
                BaslıkId = formData.BaslıkId
            };

            Database.Session.Save(konu);
            Database.Session.Flush();
            return(RedirectToAction("New"));
        }
        public IndexBlogInceleResponse IndexBlogIncele(IndexSlugRequest indexSlugRequest)
        {
            Makaleler    makaleler    = _makalelerRepository.Find(x => x.Slug == indexSlugRequest.Slug);
            Kullanicilar kullanicilar = _kullanicilarRepository.Find(x => x.Id == makaleler.KullaniciIdi);
            Konular      konular      = _konularRepository.Find(x => x.Id == makaleler.KonuIdi);
            HttpClient   client2      = new HttpClient();

            client2.BaseAddress = new Uri("http://127.0.0.1:5000/");
            HttpResponseMessage responseMessage2 = client2.GetAsync("get_chain").Result;

            responseMessage2.EnsureSuccessStatusCode();
            var            responseBody = responseMessage2.Content.ReadAsStringAsync();
            GenelChainList emp          = responseMessage2.Content.ReadAsAsync <GenelChainList>().Result;

            IndexBlogInceleResponse indexBlogInceleResponse = new IndexBlogInceleResponse();

            indexBlogInceleResponse.AltBaslik      = makaleler.AltBaslik;
            indexBlogInceleResponse.Baslik         = makaleler.Baslik;
            indexBlogInceleResponse.Biyografi      = kullanicilar.Biyografi;
            indexBlogInceleResponse.Icerik         = makaleler.Icerik;
            indexBlogInceleResponse.KonuAdi        = konular.KonuAdi;
            indexBlogInceleResponse.KullaniciAdi   = kullanicilar.KullaniciAdi;
            indexBlogInceleResponse.KullaniciResim = kullanicilar.Resim;
            indexBlogInceleResponse.Tarih          = makaleler.Tarih;
            indexBlogInceleResponse.Resim          = makaleler.Resim;
            indexBlogInceleResponse.CoinSayisi     = emp.chain.SelectMany(x => x.transactions.Where(a => a.receiver == indexSlugRequest.Slug)).Sum(a => a.amount);
            indexBlogInceleResponse.YorumSayisi    = _yorumlarRepository.List(x => x.MakalelerIdi == makaleler.Id && x.Onaylanma == true).Count();

            List <YorumlarResponse> yorumlarRes = new List <YorumlarResponse>();

            foreach (var item in _yorumlarRepository.List(x => x.MakalelerIdi == makaleler.Id && x.Onaylanma == true))
            {
                yorumlarRes.Add(new YorumlarResponse()
                {
                    KullaniciAdi = item.AdSoyad, KullaniciResim = "bos.png", Yorum = item.YapilanYorum, YorumTarihi = item.YapilanTarih
                });
            }
            ;

            indexBlogInceleResponse.liste = yorumlarRes;

            return(indexBlogInceleResponse);
        }
Exemple #6
0
        public List <Konular> KonularıGetir()
        {
            List <Konular> konular = new List <Konular>();

            using (var connection = Database.BaglantiGetir())
            {
                var comm = new SqlCommand("SELECT konu FROM tbl_konular ", connection);
                comm.ExecuteNonQuery();
                using (var read = comm.ExecuteReader())
                {
                    while (read.Read())
                    {
                        Konular konu = new Konular();
                        konu.konu = read["konu"].ToString();
                        konular.Add(konu);
                    }
                }
                connection.Close();
            }
            return(konular);
        }
Exemple #7
0
        public void KonuSil(KonuIdRequest konuIdRequest)
        {
            Konular konular = _konularRepository.Find(x => x.Id == konuIdRequest.Id);

            _konularRepository.Delete(konular);
        }