public ActionResult Edit(int id, d_detail d_detail)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    int flag = DistressReportControllerManager.updateDistressReport(id, d_detail);
                    if (flag == 1)
                    {
                        return(RedirectToAction("Index"));
                    }
                }

                ViewBag.Distress            = DistressReportControllerManager.getDistressSelectList();
                ViewBag.MCS                 = DistressReportControllerManager.getRadioStationsSelectList();
                ViewBag.LattitudeDirections = DistressReportControllerManager.getLattitudeDirectionsSelectList();
                ViewBag.LongitudeDirections = DistressReportControllerManager.getLongitudeDirectionsSelectList();

                return(View());
            }
            catch (Exception)
            {
                return(RedirectToAction("Error", "Home", new { error = "POST/DistressReport/Edit" }));
            }
        }
 public ActionResult Delete(int id, d_detail d_detail)
 {
     try
     {
         DistressReportControllerManager.deleteDistressReport(id, d_detail);
         return(RedirectToAction("Index"));
     }
     catch (Exception)
     {
         return(RedirectToAction("Error", "Home", new { error = "POST/DistressReport/Delete" }));
     }
 }
Ejemplo n.º 3
0
        //update method
        public int updateDistressReport(int id, d_detail d_detail)
        {
            try
            {
                d_detail.d_detail_last_modified_date = DateTime.Now;
                d_detail.d_detail_last_modified_by   = HttpContext.Current.User.Identity.Name;

                return(DistressReportService.updateDistressReportDB(id, d_detail));
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 4
0
        //insert method
        public int saveDistressReportDB(d_detail d_detail)
        {
            int flag = 0;

            try
            {
                db.d_detail.Add(d_detail);
                db.SaveChanges();
                flag = 1;
            }
            catch (Exception)
            {
                throw;
            }
            return(flag);
        }
Ejemplo n.º 5
0
        //insert method
        public int saveDistressReport(d_detail d_detail)
        {
            try
            {
                d_detail.d_detail_created_date       = DateTime.Now;
                d_detail.d_detail_created_by         = HttpContext.Current.User.Identity.Name;
                d_detail.d_detail_last_modified_date = DateTime.Now;
                d_detail.d_detail_last_modified_by   = HttpContext.Current.User.Identity.Name;
                d_detail.d_detail_status             = 1;

                return(DistressReportService.saveDistressReportDB(d_detail));
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 6
0
        //select method
        public d_detail getDistressReportDB(int id)
        {
            d_detail d_detail = null;

            try
            {
                d_detail = db.d_detail.Where(d => d.d_detail_id == id && d.d_detail_status == 1).FirstOrDefault();
                if (d_detail == null)
                {
                    d_detail = new d_detail();
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(d_detail);
        }
Ejemplo n.º 7
0
        //get owner data to Fax Message
        public owner getOwnerForFaxDB(int distressReportId)
        {
            d_detail         d_detail         = null;
            vessel_owner_ref vessel_owner_ref = null;
            owner            owner            = null;

            try
            {
                d_detail         = db.d_detail.Where(d => d.d_detail_id == distressReportId).FirstOrDefault();
                vessel_owner_ref = db.vessel_owner_ref.Where(vor => vor.vessel_id == d_detail.vessel_id).FirstOrDefault();
                owner            = db.owners.Where(o => o.owner_id == vessel_owner_ref.owner_id && o.owner_status == 1).FirstOrDefault();
            }
            catch (Exception)
            {
                throw;
            }
            return(owner);
        }
Ejemplo n.º 8
0
        //delete method
        public int deleteDistressReportDB(int id, d_detail d_detail)
        {
            int flag = 0;

            try
            {
                var result = db.d_detail.Where(d => d.d_detail_id == id && d.d_detail_status == 1).FirstOrDefault();
                if (result != null)
                {
                    db.Entry(result).State   = EntityState.Detached;
                    db.Entry(d_detail).State = EntityState.Modified;
                    db.SaveChanges();
                    flag = 1;
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(flag);
        }