Example #1
0
        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, 45136);

            ViewBag.Permission = permission;
            var varDetalle_del_Certificado_CC = new Detalle_del_Certificado_CCModel();

            ViewBag.ObjectId  = "45136";
            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_del_Certificado_CCApiConsumer.SetAuthHeader(_tokenManager.Token);
                var Detalle_del_Certificado_CCData = _IDetalle_del_Certificado_CCApiConsumer.GetByKeyComplete(Id).Resource.Detalle_del_Certificado_CCs[0];
                if (Detalle_del_Certificado_CCData == null)
                {
                    return(HttpNotFound());
                }

                varDetalle_del_Certificado_CC = new Detalle_del_Certificado_CCModel
                {
                    Clave         = (int)Detalle_del_Certificado_CCData.Clave
                    , Certificado = Detalle_del_Certificado_CCData.Certificado
                    , Archivo     = Detalle_del_Certificado_CCData.Archivo
                    , Fecha       = (Detalle_del_Certificado_CCData.Fecha == null ? string.Empty : Convert.ToDateTime(Detalle_del_Certificado_CCData.Fecha).ToString(ConfigurationProperty.DateFormat))
                };
            }
            if (!_tokenManager.GenerateToken())
            {
                return(Json(null, JsonRequestBehavior.AllowGet));
            }



            ViewBag.Consult = consult == 1;
            if (consult == 1)
            {
                ViewBag.Operation = "Consult";
            }
            return(View(varDetalle_del_Certificado_CC));
        }
Example #2
0
        public ActionResult AddDetalle_del_Certificado_CC(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, 45136);

            ViewBag.Permission = permission;
            if (!_tokenManager.GenerateToken())
            {
                return(null);
            }
            _IDetalle_del_Certificado_CCApiConsumer.SetAuthHeader(_tokenManager.Token);
            Detalle_del_Certificado_CCModel varDetalle_del_Certificado_CC = new Detalle_del_Certificado_CCModel();


            if (id.ToString() != "0")
            {
                var Detalle_del_Certificado_CCsData = _IDetalle_del_Certificado_CCApiConsumer.ListaSelAll(0, 1000, "Detalle_del_Certificado_CC.Clave=" + id, "").Resource.Detalle_del_Certificado_CCs;

                if (Detalle_del_Certificado_CCsData != null && Detalle_del_Certificado_CCsData.Count > 0)
                {
                    var Detalle_del_Certificado_CCData = Detalle_del_Certificado_CCsData.First();
                    varDetalle_del_Certificado_CC = new Detalle_del_Certificado_CCModel
                    {
                        Clave         = Detalle_del_Certificado_CCData.Clave
                        , Certificado = Detalle_del_Certificado_CCData.Certificado
                        , Archivo     = Detalle_del_Certificado_CCData.Archivo
                        , Fecha       = (Detalle_del_Certificado_CCData.Fecha == null ? string.Empty : Convert.ToDateTime(Detalle_del_Certificado_CCData.Fecha).ToString(ConfigurationProperty.DateFormat))
                    };
                }
            }
            if (!_tokenManager.GenerateToken())
            {
                return(Json(null, JsonRequestBehavior.AllowGet));
            }



            return(PartialView("AddDetalle_del_Certificado_CC", varDetalle_del_Certificado_CC));
        }
Example #3
0
        public ActionResult Post(bool IsNew, Detalle_del_Certificado_CCModel varDetalle_del_Certificado_CC)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    if (!_tokenManager.GenerateToken())
                    {
                        return(Json(null, JsonRequestBehavior.AllowGet));
                    }
                    _IDetalle_del_Certificado_CCApiConsumer.SetAuthHeader(_tokenManager.Token);



                    var result = "";
                    var Detalle_del_Certificado_CCInfo = new Detalle_del_Certificado_CC
                    {
                        Clave         = varDetalle_del_Certificado_CC.Clave
                        , Certificado = varDetalle_del_Certificado_CC.Certificado
                        , Archivo     = varDetalle_del_Certificado_CC.Archivo
                        , Fecha       = (!String.IsNullOrEmpty(varDetalle_del_Certificado_CC.Fecha)) ? DateTime.ParseExact(varDetalle_del_Certificado_CC.Fecha, ConfigurationProperty.DateFormat, CultureInfo.InvariantCulture as IFormatProvider) : (DateTime?)null
                    };

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

                    return(Json(result, JsonRequestBehavior.AllowGet));
                }
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
            catch (ServiceException ex)
            {
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
        }