Пример #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            VesselTbl vesselTbl = db.VesselTbls.Find(id);

            db.VesselTbls.Remove(vesselTbl);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #2
0
 public ActionResult Edit([Bind(Include = "Vessel_ID,Vessel_ScheduleID,Vessel_Type,Vessel_Size,Vessel_Name,Vessel_Approval,Vessel_Agent")] VesselTbl vesselTbl)
 {
     if (ModelState.IsValid)
     {
         db.Entry(vesselTbl).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.Vessel_ScheduleID = new SelectList(db.ScheduleTbls, "Schedule_ID", "Sailing_Route", vesselTbl.Vessel_ScheduleID);
     return(View(vesselTbl));
 }
Пример #3
0
        public ActionResult Create([Bind(Include = "Vessel_ID,Vessel_ScheduleID,Vessel_Type,Vessel_Size,Vessel_Name,Vessel_Approval,Vessel_Customer")] VesselTbl vesselTbl)
        {
            if (ModelState.IsValid)
            {
                var sche  = db.ScheduleTbls.Find(vesselTbl.Vessel_ScheduleID);
                var cus   = db.CustomerTbls.Find(vesselTbl.Vessel_Customer);
                var item  = db.ItemTbls.Include(i => i.Item_Customer).Where(i => i.Item_Customer == cus.Customer_ID);
                var itemq = from a in db.CustomerTbls
                            join a1 in db.ItemTbls on a.Customer_ID equals a1.Item_Customer
                            where a.Customer_ID.Equals(a1.Item_Customer)
                            select a1;


                if (cus.Customer_Vessel != null)
                {
                    TempData["notice"] = "Sorry this Customer has already occupied";
                    return(RedirectToAction("VesselSchedule", "ScheduleTbls"));
                }



                if (sche != null)
                {
                    sche.Space_Available = vesselTbl.Vessel_Size;
                    db.Entry(sche).State = EntityState.Modified;
                }

                if (cus != null)
                {
                    cus.Customer_Vessel = vesselTbl.Vessel_ID;
                    db.Entry(cus).State = EntityState.Modified;
                }
                foreach (var it in itemq)
                {
                    if (it.Item_Customer == cus.Customer_ID)
                    {
                        it.Item_Vessel     = vesselTbl.Vessel_ID;
                        db.Entry(it).State = EntityState.Modified;
                    }
                }
                vesselTbl.Vessel_Approval = "Pending";
                ApplicationDbContext context = new ApplicationDbContext();
                var             UserManager  = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(context));
                ApplicationUser currentUser  = UserManager.FindById(User.Identity.GetUserId());
                vesselTbl.Vessel_Agent = currentUser.Email;
                db.VesselTbls.Add(vesselTbl);
                db.SaveChanges();
                TempData["notice"] = "Your Booking has been sent to Admin for Approval";
                return(RedirectToAction("VesselSchedule", "ScheduleTbls"));
            }

            ViewBag.Vessel_ScheduleID = new SelectList(db.ScheduleTbls, "Schedule_ID", "Sailing_Route", vesselTbl.Vessel_ScheduleID);
            return(View(vesselTbl));
        }
Пример #4
0
        // GET: VesselTbls/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            VesselTbl vesselTbl = db.VesselTbls.Find(id);

            if (vesselTbl == null)
            {
                return(HttpNotFound());
            }
            return(View(vesselTbl));
        }
Пример #5
0
        // GET: VesselTbls/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            VesselTbl vesselTbl = db.VesselTbls.Find(id);

            if (vesselTbl == null)
            {
                return(HttpNotFound());
            }
            ViewBag.Vessel_ScheduleID = new SelectList(db.ScheduleTbls, "Schedule_ID", "Sailing_Route", vesselTbl.Vessel_ScheduleID);
            return(View(vesselTbl));
        }