//update method
        public int updateDistress(int id, distress distress)
        {
            try
            {
                distress.distress_last_modified_date = DateTime.Now;
                distress.distress_last_modified_by   = HttpContext.Current.User.Identity.Name;

                return(DistressService.updateDistressDB(id, distress));
            }
            catch (Exception)
            {
                throw;
            }
        }
        //insert method
        public int saveDistress(distress distress)
        {
            try
            {
                distress.distress_created_date       = DateTime.Now;
                distress.distress_created_by         = HttpContext.Current.User.Identity.Name;
                distress.distress_last_modified_date = DateTime.Now;
                distress.distress_last_modified_by   = HttpContext.Current.User.Identity.Name;
                distress.distress_status             = 1;

                return(DistressService.saveDistressDB(distress));
            }
            catch (Exception)
            {
                throw;
            }
        }
        //insert method
        public int saveDistressDB(distress distress)
        {
            int flag = 0;

            try
            {
                if (distress != null)
                {
                    db.distresses.Add(distress);
                    db.SaveChanges();
                    flag = 1;
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(flag);
        }
 public ActionResult Create(distress distress)
 {
     try
     {
         if (ModelState.IsValid)
         {
             int flag = DistressControllerManager.saveDistress(distress);
             if (flag == 1)
             {
                 return(RedirectToAction("Index"));
             }
         }
         return(View());
     }
     catch (Exception)
     {
         return(RedirectToAction("Error", "Home", new { error = "POST/Distress/Create" }));
     }
 }
        //delete method
        public int deleteDistressDB(int id, distress distress)
        {
            int flag = 0;

            try
            {
                var result = db.distresses.Where(d => d.distress_id == id && d.distress_status == 1);
                if (result != null)
                {
                    db.Entry(result).State   = EntityState.Detached;
                    db.Entry(distress).State = EntityState.Modified;
                    flag = db.SaveChanges();
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(flag);
        }
Esempio n. 6
0
 }To create a new message type create a sub-class of the MessageRouter's Message class. A message can contain any additional data that is specific to this new message type. It can also contain any additional convenience constructors and methods that you deem necessary. In this example I've kept things simple and have only added a single attribute with the call-sign of the pilot that has sent this distress message.