public ActionResult Edit(int id, FormCollection collection)
        {
            using (AuthorsDAL service = new AuthorsDAL())
            {
                //    try
                //    {
                //        service.Edit(id);
                //        TempData["Pesan"] = Helpers.KotakPesan.getPesan("Success!", "success", "Data " + author.FirstName + " successfully changed");
                //    }
                //    catch (Exception ex)
                //    {

                //        TempData["Pesan"] = Helpers.KotakPesan.getPesan("Error!", "danger", ex.Message);
                //    }

                //}
                //return RedirectToAction("Index");
                try
                {
                    // TODO: Add update logic here

                    return(RedirectToAction("Index"));
                }
                catch
                {
                    return(View());
                }
            }
        }
Example #2
0
        public ActionResult Create()
        {
            //data author
            var lstAuthor = new List <SelectListItem>();

            using (AuthorsDAL svAuthors = new AuthorsDAL())
            {
                foreach (var author in svAuthors.GetData())
                {
                    lstAuthor.Add(new SelectListItem
                    {
                        Value = author.AuthorID.ToString(),
                        Text  = author.FirstName + " " + author.LastName
                    });
                }
                ViewBag.Authors = lstAuthor;
            }
            //
            var lstCat = new List <SelectListItem>();

            using (CategoriesDAL svCat = new CategoriesDAL())
            {
                foreach (var cat in svCat.GetData())
                {
                    lstCat.Add(new SelectListItem
                    {
                        Value = cat.CategoryID.ToString(),
                        Text  = cat.CategoryName
                    });
                }
                ViewBag.Categories = lstCat;
            }
            return(View());
        }
        // GET: Author
        public ActionResult Index()
        {
            AuthorsDAL autDAL = new AuthorsDAL();
            var        model  = autDAL.getAll();

            return(View(model));
        }
Example #4
0
        // GET: Authors
        public ActionResult Index()
        {
            AuthorsDAL auto   = new AuthorsDAL();
            var        models = auto.GetAll();

            return(View(models));
        }
 // GET: Author/Edit/5
 public ActionResult Edit(int id)
 {
     using (AuthorsDAL service = new AuthorsDAL())
     {
         var author = service.GetByID(id);
         return(View(author));
     }
 }
Example #6
0
 public ActionResult Edit(int id)
 {
     using (AuthorsDAL services = new AuthorsDAL())
     {
         var result = services.GetDataById(id);
         return(View(result));
     }
 }
Example #7
0
 // GET: Authors
 public ActionResult Index()
 {
     using (AuthorsDAL service = new AuthorsDAL())
     {
         var model = service.GetData().ToList();
         if (TempData["Pesan"] != null)
         {
             ViewBag.Pesan = TempData["Pesan"].ToString();
         }
         return(View(model));
     }
 }
Example #8
0
 public ActionResult Create(Author author)
 {
     try
     {
         // TODO: Add insert logic here
         AuthorsDAL auto = new AuthorsDAL();
         auto.Create(author);
         return(RedirectToAction("Index"));
     }
     catch (Exception ex)
     {
         ViewBag.Error = ex.Message;
         return(View());
     }
 }
 public ActionResult Create(Author author)
 {
     using (AuthorsDAL service = new AuthorsDAL())
     {
         try
         {
             service.Create(author);
             // TempData["Pesan"] = Helpers.Pesan.getPesan("Sukses !", "Sukses", "Data Author " + author.FirstName + " berhasil ditambah");
             TempData["Pesan"] = Helpers.Pesan.getPesan("Success!", "success", "Data author " + author.FirstName + " berhasil di tambah");
         }
         catch (Exception ex)
         {
             TempData["Pesan"] = Helpers.Pesan.getPesan("Error!", "danger", ex.Message);
             // throw new Exception();
         }
     }
     return(RedirectToAction("Index"));
 }
 public ActionResult Create(Author author)
 {
     using (AuthorsDAL service = new AuthorsDAL())
     {
         try
         {
             service.Add(author);
             TempData["Pesan"] = Helper.KotakPesan.GetPesan("success",
                                                            "Sukses ", "Data berhasil ditambahkan");
         }
         catch (Exception ex)
         {
             TempData["Pesan"] = Helper.KotakPesan.GetPesan("danger",
                                                            "Error! ", ex.Message);
         }
     }
     return(RedirectToAction("Index"));
 }
Example #11
0
 public ActionResult Delete(int id)
 {
     using (AuthorsDAL service = new AuthorsDAL())
     {
         try
         {
             service.Delete(id);
             TempData["Pesan"] = Helpers.KotakPesan.GetPesan("Sukses !",
                                                             "success", "Data Author berhasil didelete !");
         }
         catch (Exception ex)
         {
             TempData["Pesan"] = Helpers.KotakPesan.GetPesan("Error !",
                                                             "danger", ex.Message);
         }
     }
     return(RedirectToAction("Index"));
 }
Example #12
0
 public ActionResult Edit(Author author)
 {
     using (AuthorsDAL services = new AuthorsDAL())
     {
         try
         {
             services.Edit(author);
             TempData["Pesan"] = Helpers.KotakPesan.GetPesan("Sukses !",
                                                             "success", "Data Author " + author.FirstName + " berhasil diedit");
         }
         catch (Exception ex)
         {
             TempData["Pesan"] = Helpers.KotakPesan.GetPesan("Error !",
                                                             "danger", ex.Message);
         }
     }
     return(RedirectToAction("Index"));
 }
 public ActionResult Delete(int?id)
 {
     if (id != null)
     {
         using (AuthorsDAL service = new AuthorsDAL())
         {
             try
             {
                 service.Delete(id.Value);
                 TempData["Pesan"] = Helper.KotakPesan.GetPesan("success",
                                                                "Sukses ", "Data berhasil dihapus");
             }
             catch (Exception ex)
             {
                 TempData["Pesan"] = Helper.KotakPesan.GetPesan("danger",
                                                                "Error! ", ex.Message);
             }
         }
     }
     return(RedirectToAction("Index"));
 }
 public ActionResult EditPost(int?id, Author author)
 {
     if (id == null)
     {
         return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
     }
     using (AuthorsDAL service = new AuthorsDAL())
     {
         try
         {
             service.Edit(id.Value, author);
             TempData["Pesan"] = Helper.KotakPesan.GetPesan("success",
                                                            "Sukses ", "Data author berhasil diubah");
         }
         catch (Exception ex)
         {
             TempData["Pesan"] = Helper.KotakPesan.GetPesan("danger",
                                                            "Error! ", ex.Message);
         }
     }
     return(RedirectToAction("Index"));
 }