Ejemplo n.º 1
0
        public void AddRegisterNewscast(VmRegisterNewscast vmRegisterNewscast)
        {
            if (vmRegisterNewscast == null)
            {
                throw new System.NullReferenceException("kayıt edilecek bilgi bulunamadı");
            }
            var tempNewscast = vmRegisterNewscast.GetNewscast();

            database.Newscast.Add(tempNewscast);
        }
        public static Newscast GetNewscast(this VmRegisterNewscast vmRegisterNewscast)
        {
            var newscast = new Newscast()
            {
                NewsTitle          = vmRegisterNewscast.NewsTitle,
                NewsContent        = vmRegisterNewscast.NewsContent,
                NewsImage          = vmRegisterNewscast.NewsImage,
                TimeOfCreation     = DateTime.Now,
                TimeOfModification = DateTime.Now,
                IsActive           = true
            };

            return(newscast);
        }
Ejemplo n.º 3
0
        public ActionResult Register(VmRegisterNewscast vmRegisterNewscast)
        {
            if (!ModelState.IsValid)
            {
                ModelState.AddModelError("", "Eksik alanları doldurun...");
                return(View(vmRegisterNewscast));
            }

            if (!newscastService.IsValidNewsTitle(vmRegisterNewscast.NewsTitle))
            {
                ModelState.AddModelError("", "Bu haber başlığı sisteme kayıtlıdır..");
                return(View(vmRegisterNewscast));
            }



            newscastService.AddRegisterNewscast(vmRegisterNewscast);
            newscastService.SaveDb();


            return(RedirectToAction(nameof(Index)));
        }