Esempio n. 1
0
        internal static generalNewsListReponse UpdateNews(string newsId, string newsTitle, string newsDesc, int newsCat)
        {
            NewsUpdateModel req = new NewsUpdateModel()
            {
                CategoryId      = newsCat,
                NewsDescription = newsDesc,
                NewsId          = Guid.Parse(newsId),
                NewsTitle       = newsTitle
            };
            generalNewsListReponse result = new generalNewsListReponse();

            try
            {
                var client = new HttpClient();
                client.BaseAddress = baseUri;
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                var content = new StringContent(JsonConvert.SerializeObject(req));
                content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
                var response = client.PostAsync("api/manager/UpdateNews/", content).Result;
                if (response.IsSuccessStatusCode)
                {
                    var value = response.Content.ReadAsStringAsync();

                    result = JsonConvert.DeserializeObject <generalNewsListReponse>(value.Result);
                }
                return(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 2
0
 public IActionResult EditNews(int?Id)
 {
     if (Id != null)
     {
         var entity = NewsRepository.GetNewsbyId((int)Id);
         if (entity != null)
         {
             var haber = new NewsUpdateModel()
             {
                 Id           = entity.haberId,
                 haberBasligi = entity.haberBasligi,
                 haberIcerigi = entity.haberIcerigi,
                 haberKaynagi = entity.haberKaynagi,
                 haberResmi   = entity.haberResmi,
                 haberYazari  = entity.haberYazari,
                 categoryId   = entity.categoryId,
                 isHome       = entity.isHome
             };
             return(View(haber));
         }
         else
         {
             return(NotFound());
         }
     }
     else
     {
         return(NotFound());
     }
 }
Esempio n. 3
0
        public ActionResult NewsEdit(NewsUpdateModel newsInput)
        {
            if (this.ModelState.IsValid)
            {
                var newsDb = new NewsSingle();
                newsDb.Content = this.sanitizer.Sanitize(newsInput.Content);

                this.Repo.Update(this.Context.News, newsDb, newsInput.Id);

                return(RedirectToAction("Index", "Home"));
            }

            return(View(newsInput));
        }
Esempio n. 4
0
        public IActionResult CreateNews(NewsUpdateModel newsUpdateModel)
        {
            var haber = new News()
            {
                haberBasligi = newsUpdateModel.haberBasligi,
                haberIcerigi = newsUpdateModel.haberIcerigi,
                haberKaynagi = newsUpdateModel.haberKaynagi,
                haberResmi   = newsUpdateModel.haberResmi,
                haberYazari  = newsUpdateModel.haberYazari,
                categoryId   = newsUpdateModel.categoryId,
                isHome       = newsUpdateModel.isHome
            };

            NewsRepository.AddNews(haber);
            return(RedirectToAction("NewsList"));
        }
Esempio n. 5
0
        public ActionResult NewsEdit(string id)
        {
            var newsDb = this.Repo.FindOneById <NewsSingle>(this.Context.News, id);

            if (newsDb != null)
            {
                var newsViewModel = new NewsUpdateModel()
                {
                    Id      = newsDb.Id,
                    Content = newsDb.Content
                };

                return(View(newsViewModel));
            }

            return(RedirectToAction("Index", "Home"));
        }
Esempio n. 6
0
        public IActionResult EditNews(NewsUpdateModel newsUpdateModel)
        {
            var entity = NewsRepository.GetNewsbyId(newsUpdateModel.Id);

            if (entity == null)
            {
                return(NotFound());
            }
            Console.WriteLine(newsUpdateModel.haberBasligi);
            entity.haberBasligi = newsUpdateModel.haberBasligi;
            entity.haberIcerigi = newsUpdateModel.haberIcerigi;
            entity.haberKaynagi = newsUpdateModel.haberKaynagi;
            entity.haberResmi   = newsUpdateModel.haberResmi;
            entity.haberYazari  = newsUpdateModel.haberYazari;
            entity.categoryId   = newsUpdateModel.categoryId;
            entity.isHome       = newsUpdateModel.isHome;
            NewsRepository.UpdateNews(entity);
            return(RedirectToAction("NewsList"));
        }
 public ActionResult SaveNews(NewsUpdateModel updateModel)
 {
     _newsLogic.SaveNewsRecord(updateModel.ToNewsRecord());
     return(RedirectToAction("Index"));
 }