Ejemplo n.º 1
0
        public ActionResult Post(bool IsNew, MS_Sexo_EjerciciosModel varMS_Sexo_Ejercicios)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    if (!_tokenManager.GenerateToken())
                    {
                        return(Json(null, JsonRequestBehavior.AllowGet));
                    }
                    _IMS_Sexo_EjerciciosApiConsumer.SetAuthHeader(_tokenManager.Token);



                    var result = "";
                    var MS_Sexo_EjerciciosInfo = new MS_Sexo_Ejercicios
                    {
                        Folio  = varMS_Sexo_Ejercicios.Folio
                        , Sexo = varMS_Sexo_Ejercicios.Sexo
                    };

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

                    return(Json(result, JsonRequestBehavior.AllowGet));
                }
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
            catch (ServiceException ex)
            {
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
        }
        public HttpResponseMessage Post(MS_Sexo_Ejercicios varMS_Sexo_Ejercicios)
        {
            if (ModelState.IsValid)
            {
                var data = "-1";
                try
                {
                    data = Convert.ToString(this.service.Insert(varMS_Sexo_Ejercicios));
                    var bitacora = BitacoraHelper.GetBitacora(Request, object_id, Convert.ToInt32(data), BitacoraHelper.TypeSql.INSERT, "sp_InsMS_Sexo_Ejercicios", new JavaScriptSerializer().Serialize(varMS_Sexo_Ejercicios), true);
                    serviceBitacora.Insert(bitacora);
                }
                catch (ServiceException ex)
                {
                    var bitacora = BitacoraHelper.GetBitacora(Request, object_id, 0, BitacoraHelper.TypeSql.INSERT, "sp_InsMS_Sexo_Ejercicios", new JavaScriptSerializer().Serialize(varMS_Sexo_Ejercicios), true);
                    serviceBitacora.Insert(bitacora);
                    return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message));
                }

                return(Request.CreateResponse(HttpStatusCode.OK, data, Configuration.Formatters.JsonFormatter));
            }
            else
            {
                var errors   = ModelState.SelectMany(m => m.Value.Errors.Select(err => err.ErrorMessage != string.Empty ? err.ErrorMessage : err.Exception.Message).ToList()).ToList();
                var bitacora = BitacoraHelper.GetBitacora(Request, object_id, 0, BitacoraHelper.TypeSql.INSERT, "sp_InsMS_Sexo_Ejercicios", new JavaScriptSerializer().Serialize(varMS_Sexo_Ejercicios), false, errors.ToString());
                serviceBitacora.Insert(bitacora);
                return(Request.CreateResponse(HttpStatusCode.BadRequest, errors));
            }
        }
        public HttpResponseMessage Delete(int id)
        {
            MS_Sexo_Ejercicios varMS_Sexo_Ejercicios = this.service.GetByKey(id, false);
            bool result = false;

            if (varMS_Sexo_Ejercicios == null)
            {
                return(Request.CreateResponse(HttpStatusCode.NotFound));
            }

            try
            {
                result = this.service.Delete(id);//, globalData, dataReference);
                var bitacora = BitacoraHelper.GetBitacora(Request, object_id, id, BitacoraHelper.TypeSql.DELETE, "sp_DelMS_Sexo_Ejercicios", new JavaScriptSerializer().Serialize(varMS_Sexo_Ejercicios), result);
                serviceBitacora.Insert(bitacora);
            }
            catch (ServiceException ex)
            {
                var bitacora = BitacoraHelper.GetBitacora(Request, object_id, id, BitacoraHelper.TypeSql.DELETE, "sp_DelMS_Sexo_Ejercicios", new JavaScriptSerializer().Serialize(varMS_Sexo_Ejercicios), result, ex.Message);
                serviceBitacora.Insert(bitacora);
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message));
            }

            return(Request.CreateResponse(HttpStatusCode.OK, result));
        }
        public HttpResponseMessage Get_Datos_Generales(int id)
        {
            MS_Sexo_Ejercicios entity = this.service.ListaSelAll(1, 1, "MS_Sexo_Ejercicios.Folio='" + id.ToString() + "'", "").MS_Sexo_Ejercicioss.First();
            MS_Sexo_Ejercicios result = new MS_Sexo_Ejercicios();

            result.Folio     = entity.Folio;
            result.Sexo      = entity.Sexo;
            result.Sexo_Sexo = entity.Sexo_Sexo;

            return(Request.CreateResponse(HttpStatusCode.OK, result, Configuration.Formatters.JsonFormatter));
        }
        public HttpResponseMessage PutTunnel(MS_Sexo_Ejercicios emp, string user, string password)
        {
            var client = new System.Net.WebClient();

            client.Headers = TokenManager.GetAuthenticationHeader(user, password);
            client.Headers["Content-Type"] = "application/json";
            var dataString = new JavaScriptSerializer().Serialize(emp);

            var result = client.UploadString(new Uri(baseApi + ApiControllerUrl + "/Put?Id=" + emp.Folio), "PUT"
                                             , dataString);

            return(Request.CreateResponse(HttpStatusCode.OK, result, Configuration.Formatters.JsonFormatter));
        }
        public HttpResponseMessage Put_Datos_Generales(MS_Sexo_Ejercicios varMS_Sexo_Ejercicios_Datos_Generales)
        {
            var data = "-1";

            try
            {
                data = Convert.ToString(this.service.Update_Datos_Generales(varMS_Sexo_Ejercicios_Datos_Generales));
                var bitacora = BitacoraHelper.GetBitacora(Request, object_id, varMS_Sexo_Ejercicios_Datos_Generales.Folio, BitacoraHelper.TypeSql.UPDATE, "sp_UpdMS_Sexo_Ejercicios", new JavaScriptSerializer().Serialize(varMS_Sexo_Ejercicios_Datos_Generales), true);
                serviceBitacora.Insert(bitacora);
            }
            catch (ServiceException ex)
            {
                var bitacora = BitacoraHelper.GetBitacora(Request, object_id, varMS_Sexo_Ejercicios_Datos_Generales.Folio, BitacoraHelper.TypeSql.UPDATE, "sp_UpdMS_Sexo_Ejercicios", new JavaScriptSerializer().Serialize(varMS_Sexo_Ejercicios_Datos_Generales), false, ex.Message);
                serviceBitacora.Insert(bitacora);
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message));
            }

            return(Request.CreateResponse(HttpStatusCode.OK, data, Configuration.Formatters.JsonFormatter));
        }
        public HttpResponseMessage MS_Sexo_EjerciciosGenerateID()
        {
            MS_Sexo_Ejercicios varMS_Sexo_Ejercicios = new MS_Sexo_Ejercicios();
            var data = "-1";

            try
            {
                data = Convert.ToString(this.service.Insert(varMS_Sexo_Ejercicios));
                var bitacora = BitacoraHelper.GetBitacora(Request, object_id, Convert.ToInt32(data), BitacoraHelper.TypeSql.INSERT, "sp_MS_Sexo_EjerciciosGenerateID", new JavaScriptSerializer().Serialize(varMS_Sexo_Ejercicios), true);
                serviceBitacora.Insert(bitacora);
            }
            catch (ServiceException ex)
            {
                var bitacora = BitacoraHelper.GetBitacora(Request, object_id, 0, BitacoraHelper.TypeSql.INSERT, "sp_MS_Sexo_EjerciciosGenerateID", new JavaScriptSerializer().Serialize(varMS_Sexo_Ejercicios), true);
                serviceBitacora.Insert(bitacora);
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message));
            }

            return(Request.CreateResponse(HttpStatusCode.OK, data, Configuration.Formatters.JsonFormatter));
        }
Ejemplo n.º 8
0
        public ActionResult Delete(int id)
        {
            try
            {
                if (!_tokenManager.GenerateToken())
                {
                    return(Json(null, JsonRequestBehavior.AllowGet));
                }
                _IMS_Sexo_EjerciciosApiConsumer.SetAuthHeader(_tokenManager.Token);

                MS_Sexo_Ejercicios varMS_Sexo_Ejercicios = null;
                if (id.ToString() != "0")
                {
                    string where = "";
                }
                var result = _IMS_Sexo_EjerciciosApiConsumer.Delete(id, null, null).Resource;
                return(Json(result, JsonRequestBehavior.AllowGet));
            }
            catch (ServiceException ex)
            {
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
        }