public ActionResult Edit(CausalViewModel model) {
            try{
                var svc = new CausalAppService();

                var o = new Causal{
                    CausalId = model.CausalId,
                    Name = model.Name,
                    CauseType = model.CauseType
                };

                if (model.Action == "-1"){
                    var exist = svc.GetCausal(model.CausalId) != null;
                    if (!exist){
                        svc.AddCausal(o);
                        this.ViewBag.Feed = 0;
                    } else{
                        model.Action = "-1";
                        this.ViewBag.Feed = 3;
                        return this.View(model);
                    }
                } else{
                    o.CausalId = model.CausalId;
                    if (model.IsDeleteAction == 0) svc.SaveCausal(o);
                    else svc.RemoveCausal(model.CausalId);
                    this.ViewBag.Feed = 0;
                }
            } catch (Exception){
                this.ViewBag.Feed = 1;
            }

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

            if (id != -1){
                var svc = new CausalAppService();
                var o = svc.GetCausal(id);
                model.CausalId = o.CausalId;
                model.Name = o.Name;
                model.CauseType = o.CauseType;
            } else{
                model.Action = "-1";
                model.CausalId = -1;
                model.Name = string.Empty;
                model.CauseType = string.Empty;
            }

            return this.View(model);
        }
        public DataTablesResult<CausalViewModel> GetAllRecords(DataTablesParam dataTableParam) {
            var svc = new CausalAppService();
            var lst = svc.GetAllCausal();
            var lstVm = new List<CausalViewModel>();
            foreach (var itm in lst){
                var itmVm = new CausalViewModel{
                    Name = itm.Name,
                    CausalId = itm.CausalId,
                    CauseType = itm.CauseType
                };
                var sb = new StringBuilder();
                var editUrl = this.Url.Action("Edit", "Causal");
                sb.AppendLine("<div class=\"btn-group\">");
                sb.AppendLine("<button type=\"button\" class=\"btn btn-default dropdown-toggle\" data-toggle=\"dropdown\" aria-expanded=\"false\">");
                sb.AppendLine("Acciones <span class=\"caret\"></span>");
                sb.AppendLine("</button>");
                sb.AppendLine("<ul class=\"dropdown-menu\" role=\"menu\">");
                sb.AppendLine("<li><a href=\"" + editUrl + "?id=-1\"><i class=\"fa fa-plus\"></i>&nbsp;Nuevo Registro</a></li>");
                sb.AppendLine(
                        "<li><a href=\"" + editUrl + "?id=" + itmVm.CausalId + "\"><i class=\"fa fa-edit\"></i>&nbsp;Editar " + itmVm.Name
                        + "</a></li>");
                sb.AppendLine("</ul>");
                sb.AppendLine("</div>");

                var actionButton = sb.ToString();

                itmVm.ActionButton = actionButton;
                lstVm.Add(itmVm);
            }

            var lstVmQueryable = lstVm.AsQueryable();

            return DataTablesResult.Create(lstVmQueryable, dataTableParam);
        }