public ActionResult DeleteConfirmed(int id)
        {
            AssignPackage assignPackage = db.AssignPackages.Find(id);

            db.AssignPackages.Remove(assignPackage);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public ActionResult Create([Bind(Include = "AssignPackageId,PackageId,CustomerId,AssignDate")] AssignPackage assignPackage)
        {
            if (ModelState.IsValid)
            {
                assignPackage.AssignDate = DateTime.Now.ToShortDateString();
                db.AssignPackages.Add(assignPackage);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CustomerId = new SelectList(db.customers, "CustomerId", "Firstname", assignPackage.CustomerId);
            ViewBag.PackageId  = new SelectList(db.packages, "Id", "PackageCode", assignPackage.PackageId);
            return(View(assignPackage));
        }
        // GET: AssignPackages/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            AssignPackage assignPackage = db.AssignPackages.Find(id);

            if (assignPackage == null)
            {
                return(HttpNotFound());
            }
            string category = Session["ACategory"].ToString();

            ViewBag.CustomerId = new SelectList(db.customers.Where(t => t.category == "Tour and Travel"), "CustomerId", "Firstname", assignPackage.CustomerId);
            ViewBag.PackageId  = new SelectList(db.packages, "Id", "PackageCode", assignPackage.PackageId);
            return(View(assignPackage));
        }
 public ActionResult Edit([Bind(Include = "AssignPackageId,PackageId,CustomerId,AssignDate")] AssignPackage assignPackage)
 {
     if (Session["ACategory"] != null)
     {
         if (Session["ACategory"].ToString() == "Tour and Travel")
         {
             if (ModelState.IsValid)
             {
                 db.Entry(assignPackage).State = EntityState.Modified;
                 db.SaveChanges();
                 return(RedirectToAction("Index"));
             }
             ViewBag.CustomerId = new SelectList(db.customers, "CustomerId", "Firstname", assignPackage.CustomerId);
             ViewBag.PackageId  = new SelectList(db.packages, "Id", "PackageCode", assignPackage.PackageId);
             return(View(assignPackage));
         }
     }
     return(new HttpStatusCodeResult(HttpStatusCode.NotFound));
 }
 // GET: AssignPackages/Details/5
 public ActionResult Details(int?id)
 {
     if (Session["ACategory"] != null)
     {
         if (Session["ACategory"].ToString() == "Tour and Travel")
         {
             if (id == null)
             {
                 return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
             }
             AssignPackage assignPackage = db.AssignPackages.Include(m => m.Customer).Include(a => a.Customer).Include(a => a.Package).Where(m => m.AssignPackageId == id).SingleOrDefault();
             if (assignPackage == null)
             {
                 return(HttpNotFound());
             }
             return(View(assignPackage));
         }
     }
     return(new HttpStatusCodeResult(HttpStatusCode.NotFound));
 }
 // GET: AssignPackages/Delete/5
 public ActionResult Delete(int?id)
 {
     if (Session["ACategory"] != null)
     {
         if (Session["ACategory"].ToString() == "Tour and Travel")
         {
             if (id == null)
             {
                 return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
             }
             AssignPackage assignPackage = db.AssignPackages.Find(id);
             if (assignPackage == null)
             {
                 return(HttpNotFound());
             }
             return(View(assignPackage));
         }
     }
     return(new HttpStatusCodeResult(HttpStatusCode.NotFound));
 }