Exemplo n.º 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, 45191);

            ViewBag.Permission = permission;
            var varDetalle_Historico_MPO = new Detalle_Historico_MPOModel();

            ViewBag.ObjectId  = "45191";
            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_Historico_MPOApiConsumer.SetAuthHeader(_tokenManager.Token);
                var Detalle_Historico_MPOData = _IDetalle_Historico_MPOApiConsumer.GetByKeyComplete(Id).Resource.Detalle_Historico_MPOs[0];
                if (Detalle_Historico_MPOData == null)
                {
                    return(HttpNotFound());
                }

                varDetalle_Historico_MPO = new Detalle_Historico_MPOModel
                {
                    Clave     = (int)Detalle_Historico_MPOData.Clave
                    , Fecha   = (Detalle_Historico_MPOData.Fecha == null ? string.Empty : Convert.ToDateTime(Detalle_Historico_MPOData.Fecha).ToString(ConfigurationProperty.DateFormat))
                    , Hora    = Detalle_Historico_MPOData.Hora
                    , Usuario = Detalle_Historico_MPOData.Usuario
                    , Estatus = Detalle_Historico_MPOData.Estatus
                };
            }
            if (!_tokenManager.GenerateToken())
            {
                return(Json(null, JsonRequestBehavior.AllowGet));
            }



            ViewBag.Consult = consult == 1;
            if (consult == 1)
            {
                ViewBag.Operation = "Consult";
            }
            return(View(varDetalle_Historico_MPO));
        }
Exemplo n.º 2
0
        public ActionResult AddDetalle_Historico_MPO(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, 45191);

            ViewBag.Permission = permission;
            if (!_tokenManager.GenerateToken())
            {
                return(null);
            }
            _IDetalle_Historico_MPOApiConsumer.SetAuthHeader(_tokenManager.Token);
            Detalle_Historico_MPOModel varDetalle_Historico_MPO = new Detalle_Historico_MPOModel();


            if (id.ToString() != "0")
            {
                var Detalle_Historico_MPOsData = _IDetalle_Historico_MPOApiConsumer.ListaSelAll(0, 1000, "Detalle_Historico_MPO.Clave=" + id, "").Resource.Detalle_Historico_MPOs;

                if (Detalle_Historico_MPOsData != null && Detalle_Historico_MPOsData.Count > 0)
                {
                    var Detalle_Historico_MPOData = Detalle_Historico_MPOsData.First();
                    varDetalle_Historico_MPO = new Detalle_Historico_MPOModel
                    {
                        Clave     = Detalle_Historico_MPOData.Clave
                        , Fecha   = (Detalle_Historico_MPOData.Fecha == null ? string.Empty : Convert.ToDateTime(Detalle_Historico_MPOData.Fecha).ToString(ConfigurationProperty.DateFormat))
                        , Hora    = Detalle_Historico_MPOData.Hora
                        , Usuario = Detalle_Historico_MPOData.Usuario
                        , Estatus = Detalle_Historico_MPOData.Estatus
                    };
                }
            }
            if (!_tokenManager.GenerateToken())
            {
                return(Json(null, JsonRequestBehavior.AllowGet));
            }



            return(PartialView("AddDetalle_Historico_MPO", varDetalle_Historico_MPO));
        }
Exemplo n.º 3
0
        public ActionResult Post(bool IsNew, Detalle_Historico_MPOModel varDetalle_Historico_MPO)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    if (!_tokenManager.GenerateToken())
                    {
                        return(Json(null, JsonRequestBehavior.AllowGet));
                    }
                    _IDetalle_Historico_MPOApiConsumer.SetAuthHeader(_tokenManager.Token);



                    var result = "";
                    var Detalle_Historico_MPOInfo = new Detalle_Historico_MPO
                    {
                        Clave     = varDetalle_Historico_MPO.Clave
                        , Fecha   = (!String.IsNullOrEmpty(varDetalle_Historico_MPO.Fecha)) ? DateTime.ParseExact(varDetalle_Historico_MPO.Fecha, ConfigurationProperty.DateFormat, CultureInfo.InvariantCulture as IFormatProvider) : (DateTime?)null
                        , Hora    = varDetalle_Historico_MPO.Hora
                        , Usuario = varDetalle_Historico_MPO.Usuario
                        , Estatus = varDetalle_Historico_MPO.Estatus
                    };

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

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