Exemple #1
0
        public ActionResult Create(Boat boat)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    //appending the name with id
                    // store the file inside ~/project folder(Img)
                    HttpPostedFileBase file = boat.Postedfile;
                    boat.Image = Path.GetFileName(file.FileName);
                    string name   = Path.GetFileNameWithoutExtension(boat.Image); //getting file name without extension
                    var    ext    = Path.GetExtension(file.FileName);
                    string myfile = name + ext;
                    var    path   = Path.Combine(Server.MapPath("~/Content/Images"), myfile);
                    file.SaveAs(path);
                    BoatDBHandle sdb = new BoatDBHandle();

                    if (sdb.AddBoat(boat))
                    {
                        ViewBag.Message = "Boat Details Added Successfully";
                        ModelState.Clear();
                    }
                }
                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                return(View("Index"));
            }
        }
Exemple #2
0
        // GET: Boats
        public ActionResult Index()
        {
            BoatDBHandle dbhandle = new BoatDBHandle();

            ModelState.Clear();
            return(View(dbhandle.GetBoat()));
        }
Exemple #3
0
 public ActionResult Buy(int id, Customer cust)
 {
     try
     {
         BoatDBHandle sdb = new BoatDBHandle();
         sdb.RentedBoat(cust);
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Exemple #4
0
 // GET: Boats/Delete/5
 public ActionResult Delete(int id)
 {
     try
     {
         BoatDBHandle sdb = new BoatDBHandle();
         if (sdb.DeleteBoat(id))
         {
             ViewBag.AlertMsg = "Boat Deleted Successfully";
         }
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Exemple #5
0
 public ActionResult Return(int id, Customer cust)
 {
     try
     {
         BoatDBHandle    sdb      = new BoatDBHandle();
         List <Customer> customer = sdb.ReturnBoat(cust);
         foreach (Customer k in customer)
         {
             return(View(k));
         }
         return(View());
     }
     catch
     {
         return(View());
     }
 }
Exemple #6
0
        public ActionResult Return(int?id)
        {
            BoatDBHandle sdb = new BoatDBHandle();

            return(View());
        }