예제 #1
0
        public ActionResult AddBelt(Belt belt)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(View("AddBelt", belt));
                }

                else
                {
                    BeltBL             beltBL = new BeltBL();
                    HttpPostedFileBase file   = Request.Files["imageFile"];
                    if (file != null && file.ContentLength > 0)
                    {
                        belt.ProductImage = file.FileName;
                        file.SaveAs(HttpContext.Server.MapPath("../Images/") + belt.ProductImage);
                    }

                    beltBL.AddBelt(belt);
                    return(RedirectToAction("BeltList"));
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                return(View());
            }
        }
예제 #2
0
        public ActionResult BeltList()
        {
            BeltListVM  beltListVM = new BeltListVM();
            BeltBL      beltBL     = new BeltBL();
            List <Belt> beltList   = new List <Belt>();

            beltListVM.BeltVMList = BeltList2BeltVMList(beltBL.GetBeltList());

            return(View(beltListVM));
        }
예제 #3
0
        public ActionResult EditBelt(Belt belt)
        {
            try
            {
                BeltBL beltBL = new BeltBL();
                beltBL.EditBelt(belt.BeltId, belt.Name, belt.Cost, belt.Description);

                return(RedirectToAction("BeltList"));
            }
            catch
            {
                return(View());
            }
        }
예제 #4
0
        //public ActionResult DeleteBelt()
        //{

        //    return View();
        //}


        //[HttpPost]
        public ActionResult DeleteBelt(Belt belt)
        {
            try
            {
                BeltBL beltBL = new BeltBL();
                beltBL.DeleteBelt(belt.BeltId);

                return(RedirectToAction("BeltList"));
            }
            catch
            {
                return(View());
            }
        }