Example #1
0
        public ActionResult deleteAlert(dbAlert alert)
        {
            string result = alertService.deleteAlert(alert);

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Example #2
0
        public ActionResult updateAlertData(string alertClassID, string alertClassName, string alertName, string editAlertID, string startDate, string endDate, List <polygonID> polygonIDs, List <polygonNames> polygonNames, List <AV> alertVehicles, string alertValue, bool TNDB)
        {
            DateTime s = DateTime.Now;
            DateTime e = DateTime.Now.AddYears(5);

            if (startDate != "")
            {
                s = Convert.ToDateTime(startDate).ToUniversalTime();
            }

            if (endDate != "")
            {
                e = Convert.ToDateTime(endDate).ToUniversalTime();
            }

            //create alert class
            dbAlert alert = new dbAlert();

            if (editAlertID == null || editAlertID == "")
            {
                alert.AlertID = Guid.NewGuid();
            }
            else
            {
                alert.AlertID = new Guid(editAlertID);
            }
            alert.AlertActive       = true;
            alert.AlertStartTime    = s;
            alert.AlertEndTime      = e;
            alert.AlertType         = "N";
            alert.AlertClassID      = new Guid(alertClassID);
            alert.AlertFriendlyName = alertName;
            alert.minVal            = alertValue;
            alert.NDB = TNDB;

            //create polygon list
            List <alertGeoFence> fences = new List <alertGeoFence>();

            if (polygonIDs != null)
            {
                foreach (polygonID pg in polygonIDs)
                {
                    alertGeoFence fence = new alertGeoFence();
                    fence.AlertID    = alert.AlertID;
                    fence.GeoFenceID = new Guid(pg.id);
                    fences.Add(fence);
                }
            }

            //list of vehicles
            List <alertVehicle> vehicles = new List <alertVehicle>();

            foreach (AV veh in alertVehicles)
            {
                alertVehicle vehicle = new alertVehicle();
                vehicle.AlertAction = veh.email;
                vehicle.AlertID     = alert.AlertID;
                vehicle.VehicleID   = new Guid(veh.id);
                vehicles.Add(vehicle);
            }

            string results = alertService.updateAlertData(alert, fences, vehicles);

            return(Json("OK", JsonRequestBehavior.AllowGet));
        }