public ActionResult Create() { var empty = new MyNewViewModel(); var data = empty.ToVM(); return(View(data)); }
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")); }
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")); }
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()); } }
public ActionResult Delete(int id, MyNewViewModel myNew) { var data = AutoMapperHelper.MapToSameViewModel <MyNew, MyNewViewModel>(_myNewService.GetById(id)); return(View(data.ToVM())); }