Exemple #1
0
 public ActionResult Create(Tamu tamu)
 {
     //cek apakah user sudah login
     if (Session["username"] == null)
     {
         if (User.Identity.IsAuthenticated)
         {
             Session["username"] = User.Identity.Name;
         }
         else
         {
             var tempUser = Guid.NewGuid().ToString();
             Session["username"] = tempUser;
         }
     }
     using (TamuDAL tmbh = new TamuDAL())
     {
         try
         {
             tmbh.TambahTamu(tamu);
         }
         catch (Exception ex)
         {
             throw new Exception(ex.Message);
         }
     }
     return(RedirectToAction("Index"));
 }
Exemple #2
0
 public ActionResult Delete(int id)
 {
     using (TamuDAL service = new TamuDAL())
     {
         service.Delete(id);
     }
     return(RedirectToAction("Index"));
 }
Exemple #3
0
 public ActionResult Edit(Tamu tamu)
 {
     using (TamuDAL services = new TamuDAL())
     {
         services.Edit(tamu);
     }
     return(RedirectToAction("Index"));
 }
Exemple #4
0
 public ActionResult Edit(int id)
 {
     using (TamuDAL services = new TamuDAL())
     {
         var result = services.GetItemByID(id);
         return(View(result));
     }
 }
Exemple #5
0
 public ActionResult Create(Tamu tamu)
 {
     using (TamuDAL service = new TamuDAL())
     {
         service.Add(tamu);
     }
     return(RedirectToAction("Index"));
 }
Exemple #6
0
 public ActionResult Search(string txtSearch)
 {
     using (TamuDAL svCat = new TamuDAL())
     {
         var results = svCat.Search(txtSearch).ToList();
         return(View("Index", results));
     }
 }
Exemple #7
0
 // GET: Tamu
 public ActionResult Index()
 {
     using (TamuDAL tamu = new TamuDAL())
     {
         string username =
             Session["username"] != null ? Session["username"].ToString() : string.Empty;
         return(View(tamu.GetData().ToList()));
     }
 }
Exemple #8
0
        public ActionResult IndexUser()
        {
            string username = Session["username"].ToString();

            using (TamuDAL service = new TamuDAL())
            {
                return(View(service.GetDataByUsername(username).ToList()));
            }
        }
Exemple #9
0
 // GET: Tamu
 public ActionResult Index()
 {
     using (TamuDAL service = new TamuDAL())
     {
         var model = service.GetData().ToList();
         if (TempData["Pesan"] != null)
         {
             ViewBag.Pesan = TempData["Pesan"].ToString();
         }
         return(View(model));
     }
 }
Exemple #10
0
 public ActionResult Create()
 {
     if (User.Identity.IsAuthenticated)
     {
         using (TamuDAL service = new TamuDAL())
         {
             string username = Session["username"] != null ? Session["username"].ToString() : string.Empty;
             return(View(service.GetByUser(username)));
         }
     }
     else
     {
         return(RedirectToAction("Login", "Account"));
     }
 }