/// <summary>
        /// Edits the specified identifier.
        /// </summary>
        /// <param name="id">The identifier.</param>
        /// <returns>ActionResult.</returns>
        public ActionResult Edit(int id)
        {
            var model = new AlertStateViewModel();

            if (id != -1)
            {
                var svc = new AlertStateAppService();
                var o = svc.GetAlertState(id);
                model.AlertStateId = o.AlertStateId;
                model.Name = o.Name;
            

            }
            else
            {
                model.Action = "-1";
                model.AlertStateId = -1;
                model.Name = string.Empty;
                
            }



            return View(model);
        }
        public ActionResult Edit(AlertStateViewModel model)
        {



            try
            {
                var svc = new AlertStateAppService();

                var o = new AlertState
                {
                    AlertStateId= model.AlertStateId,
                    Name = model.Name,
                    

                };

                if (model.Action == "-1")
                {
                    var exist = svc.GetAlertState(model.AlertStateId)!=null;
                    if (!exist)
                    {
                        svc.AddAlertState(o);
                        ViewBag.Feed = 0;
                    }
                    else
                    {
                        model.Action = "-1";
                        ViewBag.Feed = 3;
                        return View(model);
                    }
                }
                else
                {
                    o.AlertStateId= model.AlertStateId;
                    if (model.IsDeleteAction == 0)
                    {

                        svc.SaveAlertState(o);
                    }
                    else
                    {
                        svc.RemoveAlertState(model.AlertStateId);
                    }
                    ViewBag.Feed = 0;
                }
            }
            catch (Exception)
            {
                ViewBag.Feed = 1;

            }

            return View(model);
        }