예제 #1
0
        //create vessel
        public int createVesselDB(vessel_owner_ref vessel_owner_ref)
        {
            int vessel_id = 0;

            try
            {
                vessel getVesselObject = db.vessels.Where(v => v.registration_id == vessel_owner_ref.vessel.registration_id &&
                                                          v.vessel_no.Equals(vessel_owner_ref.vessel.vessel_no) && v.district_id == vessel_owner_ref.vessel.district_id &&
                                                          v.vessel_status == 1).FirstOrDefault();

                //Vessel is not exist
                if (getVesselObject == null)
                {
                    db.vessel_owner_ref.Add(vessel_owner_ref);  //Save vessel and owner
                    db.SaveChanges();

                    vessel getAboveVesselObject = db.vessels.Where(v => v.registration_id == vessel_owner_ref.vessel.registration_id &&
                                                                   v.vessel_no.Equals(vessel_owner_ref.vessel.vessel_no) && v.district_id == vessel_owner_ref.vessel.district_id &&
                                                                   v.vessel_status == 1).FirstOrDefault();

                    vessel_id = getAboveVesselObject.vessel_id;  //return vessel id after the inserted
                }
                //Vessel is exist
                else
                {
                    vessel_id = getVesselObject.vessel_id;  //return vessel id that already created
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(vessel_id);
        }
예제 #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            vessel vessel = db.vessels.Find(id);

            db.vessels.Remove(vessel);
            db.SaveChanges();
            return(RedirectToAction("VesselList"));
        }
예제 #3
0
 public ActionResult EditVessel([Bind(Include = "vesselID,VesselRegNo,ownerID,availWeight,availVolume,vesselName,enteredDate,enteredUser")] vessel vessel)
 {
     if (ModelState.IsValid)
     {
         db.Entry(vessel).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("VesselList"));
     }
     ViewBag.ownerID = new SelectList(db.users, "userID", "username", vessel.ownerID);
     return(View(vessel));
 }
예제 #4
0
        //update method
        public int updateVessel(int id, vessel vessel)
        {
            try
            {
                vessel.vessel_last_modified_date = DateTime.Now;
                vessel.vessel_last_modified_by   = HttpContext.Current.User.Identity.Name;

                return(VesselsService.updateVesselDB(id, vessel));
            }
            catch (Exception)
            {
                throw;
            }
        }
예제 #5
0
        // GET: vessels/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            vessel vessel = db.vessels.Find(id);

            if (vessel == null)
            {
                return(HttpNotFound());
            }
            return(View(vessel));
        }
예제 #6
0
        public ActionResult AddVessel([Bind(Include = "vesselID,VesselRegNo,ownerID,availWeight,availVolume,vesselName,enteredDate,enteredUser")] vessel vessel)
        {
            if (ModelState.IsValid)
            {
                vessel.enteredUser = 1;
                vessel.enteredDate = DateTime.Now;
                db.vessels.Add(vessel);
                db.SaveChanges();
                return(RedirectToAction("VesselList"));
            }

            ViewBag.ownerID = new SelectList(db.users, "userID", "username", vessel.ownerID);
            return(View(vessel));
        }
예제 #7
0
        // GET: vessels/Edit/5
        public ActionResult EditVessel(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            vessel vessel = db.vessels.Find(id);

            if (vessel == null)
            {
                return(HttpNotFound());
            }
            ViewBag.ownerID = new SelectList(db.users, "userID", "username", vessel.ownerID);
            return(View(vessel));
        }
예제 #8
0
        //update method
        public int updateVesselDB(int id, vessel vessel)
        {
            int flag = 0;

            try
            {
                var result = db.vessels.Where(v => v.vessel_id == id).FirstOrDefault();
                if (result != null)
                {
                    db.Entry(result).State = EntityState.Detached;
                    db.Entry(vessel).State = EntityState.Modified;
                    db.SaveChanges();
                    flag = 1;
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(flag);
        }
예제 #9
0
        //get Vessel Id For Renewal
        public licence getVesselIdForRenewalDB(string SearchText)
        {
            licence licence = new licence();

            try
            {
                vessel Vessel = db.vessels.Where(v => v.vessel_status == 1 && v.registration.registration_code.Equals("IMUL-A-") &&
                                                 v.vessel_no.Contains(SearchText.Substring(7, 4)) && v.district.district_code.Contains(SearchText.Substring(11, 3))).FirstOrDefault();
                //get the vessel object according to the searchText and that vessel_id will set to a new licence's vessel_id
                if (Vessel != null)
                {
                    if (Vessel.vessel_id != 0)
                    {
                        licence.vessel_id = Vessel.vessel_id;    //return vessel_id fixed licence object to the view
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(licence);
        }
예제 #10
0
        public ActionResult Edit(int id, vessel vessel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    int status = VesselsControllerManager.updateVessel(id, vessel);
                    if (status == 1)
                    {
                        return(RedirectToAction("Index"));
                    }
                }
                ViewBag.Registration = VesselsControllerManager.getRegistrationSelectList();
                ViewBag.Districts    = VesselsControllerManager.getDistrictsSelectList();
                ViewBag.Applications = VesselsControllerManager.getApplicationSelectList();

                return(View());
            }
            catch (Exception ex)
            {
                return(RedirectToAction("Error", "Home", new { error = "POST/Vessels/Edit/int" }));
            }
        }
예제 #11
0
 public Brewery()
 {
     HLT = new vessel(Vessels.HLT);
     MLT = new vessel(Vessels.MLT);
     BK = new vessel(Vessels.BK);
     Pump1 = new pump();
     Pump2 = new pump();
 }