예제 #1
0
        public ActionResult Create()
        {
            var empty = new MyNewViewModel();
            var data  = empty.ToVM();

            return(View(data));
        }
예제 #2
0
 public ActionResult Create(MyNewViewModel myNew)
 {
     if (!ModelState.IsValid)
     {
         ErrorNotification("Kayıt Eklenemedi!");
         return(RedirectToAction("Create"));
     }
     _myNewService.Add(new MyNew
     {
         //TODO:Alanlar buraya yazılacak
         //Örn:BrandName = brand.BrandName,
     });
     SuccessNotification("Kayıt Eklendi.");
     return(RedirectToAction("MyNewIndex"));
 }
예제 #3
0
 public ActionResult Create(MyNewViewModel myNew)
 {
     if (!ModelState.IsValid)
     {
         ErrorNotification("Kayıt Eklenemedi!");
         return(RedirectToAction("Create"));
     }
     _myNewService.Add(new MyNew
     {
         NewsName     = myNew.NewsName,
         NewsImage    = myNew.NewsImage,
         NewsImageExt = ".png",
         Description  = myNew.Description,
         NewsType     = myNew.NewsType,
         IsActive     = myNew.IsActive
     });
     SuccessNotification("Kayıt Eklendi.");
     return(RedirectToAction("MyNewIndex"));
 }
예제 #4
0
 public ActionResult Edit(MyNewViewModel myNew)
 {
     try
     {
         _myNewService.Update(new  MyNew
         {
             NewsName     = myNew.NewsName,
             NewsImage    = myNew.NewsImage,
             NewsImageExt = ".png",
             Description  = myNew.Description,
             NewsType     = myNew.NewsType,
             IsActive     = myNew.IsActive,
             NewsId       = myNew.NewsId
         });
         SuccessNotification("Kayıt Güncellendi");
         return(RedirectToAction("MyNewIndex"));
     }
     catch
     {
         return(View());
     }
 }
예제 #5
0
        public ActionResult Delete(int id, MyNewViewModel myNew)
        {
            var data = AutoMapperHelper.MapToSameViewModel <MyNew, MyNewViewModel>(_myNewService.GetById(id));

            return(View(data.ToVM()));
        }