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

            if (id != "-1")
            {
                var svc = new DiseaseAppService();
                var o = svc.GetDisease(id);
                model.DiseaseId = o.DiseaseId;
                model.Name = o.Name;

                model.DiseaseCategoryId = o.DiseaseCategoryId;
                model.DiseaseCategoryName = o.DiseaseCategory.Name;

                


            }
            else
            {
                model.Action = "-1";
                model.DiseaseId = "-1";
                model.Name = string.Empty;
                model.DiseaseCategoryId =  "-1";
                model.DiseaseCategoryName = string.Empty;

            }



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



            try
            {
                var svc = new DiseaseAppService();

                var o = new Disease
                {
                    DiseaseId= model.DiseaseId,
                    Name = model.Name,
                          DiseaseCategoryId=model.DiseaseCategory
       

                };

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

                        svc.SaveDisease(o);
                    }
                    else
                    {
                        svc.RemoveDisease(model.DiseaseId);
                    }
                    ViewBag.Feed = 0;
                }
            }
            catch (Exception)
            {
                ViewBag.Feed = 1;

            }

            return View(model);
        }
        public DataTablesResult<DiseaseViewModel> GetAllRecords(DataTablesParam dataTableParam)
        {

            var svc = new DiseaseAppService();
            var lst = svc.GetAllDisease();
            var lstVm = new List<DiseaseViewModel>();
            foreach (var itm in lst)
            {

                var itmVm = new DiseaseViewModel
                {

                    Name = itm.Name,
                    DiseaseId= itm.DiseaseId,
                    DiseaseCategoryName = itm.DiseaseCategory.Name,

                };

              




                var sb = new StringBuilder();

                string editUrl = Url.Action("Edit", "Disease");
                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.DiseaseId+ "\"><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);

        }