public ActionResult Post(bool IsNew, Detalle_Terapia_HormonalModel varDetalle_Terapia_Hormonal)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    if (!_tokenManager.GenerateToken())
                    {
                        return(Json(null, JsonRequestBehavior.AllowGet));
                    }
                    _IDetalle_Terapia_HormonalApiConsumer.SetAuthHeader(_tokenManager.Token);



                    var result = "";
                    var Detalle_Terapia_HormonalInfo = new Detalle_Terapia_Hormonal
                    {
                        Folio    = varDetalle_Terapia_Hormonal.Folio
                        , Nombre = varDetalle_Terapia_Hormonal.Nombre
                        , Dosis  = varDetalle_Terapia_Hormonal.Dosis
                    };

                    result = !IsNew?
                             _IDetalle_Terapia_HormonalApiConsumer.Update(Detalle_Terapia_HormonalInfo, null, null).Resource.ToString() :
                                 _IDetalle_Terapia_HormonalApiConsumer.Insert(Detalle_Terapia_HormonalInfo, null, null).Resource.ToString();

                    return(Json(result, JsonRequestBehavior.AllowGet));
                }
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
            catch (ServiceException ex)
            {
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
        }
        public ActionResult Create(int Id = 0, int consult = 0)
        {
            int ModuleId   = (Session["CurrentModuleId"] != null) ? Convert.ToInt32(Session["CurrentModuleId"]) : 0;
            var permission = PermissionHelper.GetRoleObjectPermission(SessionHelper.Role, 44345);

            ViewBag.Permission = permission;
            var varDetalle_Terapia_Hormonal = new Detalle_Terapia_HormonalModel();

            ViewBag.ObjectId  = "44345";
            ViewBag.Operation = "New";

            ViewBag.IsNew = true;



            if ((Id.GetType() == typeof(string) && Id.ToString() != "") || ((Id.GetType() == typeof(int) || Id.GetType() == typeof(Int16) || Id.GetType() == typeof(Int32) || Id.GetType() == typeof(Int64) || Id.GetType() == typeof(short)) && Id.ToString() != "0"))
            {
                ViewBag.IsNew     = false;
                ViewBag.Operation = "Update";
                if (!_tokenManager.GenerateToken())
                {
                    return(Json(null, JsonRequestBehavior.AllowGet));
                }
                _IDetalle_Terapia_HormonalApiConsumer.SetAuthHeader(_tokenManager.Token);
                var Detalle_Terapia_HormonalData = _IDetalle_Terapia_HormonalApiConsumer.GetByKeyComplete(Id).Resource.Detalle_Terapia_Hormonals[0];
                if (Detalle_Terapia_HormonalData == null)
                {
                    return(HttpNotFound());
                }

                varDetalle_Terapia_Hormonal = new Detalle_Terapia_HormonalModel
                {
                    Folio    = (int)Detalle_Terapia_HormonalData.Folio
                    , Nombre = Detalle_Terapia_HormonalData.Nombre
                    , Dosis  = Detalle_Terapia_HormonalData.Dosis
                };
            }
            if (!_tokenManager.GenerateToken())
            {
                return(Json(null, JsonRequestBehavior.AllowGet));
            }



            ViewBag.Consult = consult == 1;
            if (consult == 1)
            {
                ViewBag.Operation = "Consult";
            }
            return(View(varDetalle_Terapia_Hormonal));
        }
        public ActionResult AddDetalle_Terapia_Hormonal(int rowIndex = 0, int functionMode = 0, int id = 0)
        {
            int ModuleId = (Session["CurrentModuleId"] != null) ? Convert.ToInt32(Session["CurrentModuleId"]) : 0;

            ViewBag.currentRowIndex = rowIndex;
            ViewBag.functionMode    = functionMode;
            ViewBag.Consult         = false;
            var permission = PermissionHelper.GetRoleObjectPermission(SessionHelper.Role, 44345);

            ViewBag.Permission = permission;
            if (!_tokenManager.GenerateToken())
            {
                return(null);
            }
            _IDetalle_Terapia_HormonalApiConsumer.SetAuthHeader(_tokenManager.Token);
            Detalle_Terapia_HormonalModel varDetalle_Terapia_Hormonal = new Detalle_Terapia_HormonalModel();


            if (id.ToString() != "0")
            {
                var Detalle_Terapia_HormonalsData = _IDetalle_Terapia_HormonalApiConsumer.ListaSelAll(0, 1000, "Detalle_Terapia_Hormonal.Folio=" + id, "").Resource.Detalle_Terapia_Hormonals;

                if (Detalle_Terapia_HormonalsData != null && Detalle_Terapia_HormonalsData.Count > 0)
                {
                    var Detalle_Terapia_HormonalData = Detalle_Terapia_HormonalsData.First();
                    varDetalle_Terapia_Hormonal = new Detalle_Terapia_HormonalModel
                    {
                        Folio    = Detalle_Terapia_HormonalData.Folio
                        , Nombre = Detalle_Terapia_HormonalData.Nombre
                        , Dosis  = Detalle_Terapia_HormonalData.Dosis
                    };
                }
            }
            if (!_tokenManager.GenerateToken())
            {
                return(Json(null, JsonRequestBehavior.AllowGet));
            }



            return(PartialView("AddDetalle_Terapia_Hormonal", varDetalle_Terapia_Hormonal));
        }