Exemple #1
0
        public ActionResult Post(bool IsNew, Tipo_de_RutinaModel varTipo_de_Rutina)
        {
            try
            {
                //if (ModelState.IsValid)
                //{
                if (!_tokenManager.GenerateToken())
                {
                    return(Json(null, JsonRequestBehavior.AllowGet));
                }
                _ITipo_de_RutinaApiConsumer.SetAuthHeader(_tokenManager.Token);



                var result             = "";
                var Tipo_de_RutinaInfo = new Tipo_de_Rutina
                {
                    Folio         = varTipo_de_Rutina.Folio
                    , Descripcion = varTipo_de_Rutina.Descripcion
                };

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

                Session["KeyValueInserted"] = result;
                return(Json(result, JsonRequestBehavior.AllowGet));
                //}
                //return Json(false, JsonRequestBehavior.AllowGet);
            }
            catch (ServiceException ex)
            {
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
        }
Exemple #2
0
        public HttpResponseMessage Post(Tipo_de_Rutina varTipo_de_Rutina)
        {
            if (ModelState.IsValid)
            {
                var data = "-1";
                try
                {
                    data = Convert.ToString(this.service.Insert(varTipo_de_Rutina));
                    var bitacora = BitacoraHelper.GetBitacora(Request, object_id, Convert.ToInt32(data), BitacoraHelper.TypeSql.INSERT, "sp_InsTipo_de_Rutina", new JavaScriptSerializer().Serialize(varTipo_de_Rutina), true);
                    serviceBitacora.Insert(bitacora);
                }
                catch (ServiceException ex)
                {
                    var bitacora = BitacoraHelper.GetBitacora(Request, object_id, 0, BitacoraHelper.TypeSql.INSERT, "sp_InsTipo_de_Rutina", new JavaScriptSerializer().Serialize(varTipo_de_Rutina), 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_InsTipo_de_Rutina", new JavaScriptSerializer().Serialize(varTipo_de_Rutina), false, errors.ToString());
                serviceBitacora.Insert(bitacora);
                return(Request.CreateResponse(HttpStatusCode.BadRequest, errors));
            }
        }
Exemple #3
0
        public HttpResponseMessage Delete(int id)
        {
            Tipo_de_Rutina varTipo_de_Rutina = this.service.GetByKey(id, false);
            bool           result            = false;

            if (varTipo_de_Rutina == 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_DelTipo_de_Rutina", new JavaScriptSerializer().Serialize(varTipo_de_Rutina), result);
                serviceBitacora.Insert(bitacora);
            }
            catch (ServiceException ex)
            {
                var bitacora = BitacoraHelper.GetBitacora(Request, object_id, id, BitacoraHelper.TypeSql.DELETE, "sp_DelTipo_de_Rutina", new JavaScriptSerializer().Serialize(varTipo_de_Rutina), result, ex.Message);
                serviceBitacora.Insert(bitacora);
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message));
            }

            return(Request.CreateResponse(HttpStatusCode.OK, result));
        }
Exemple #4
0
        public HttpResponseMessage Get_Datos_Generales(int id)
        {
            Tipo_de_Rutina entity = this.service.ListaSelAll(1, 1, "Tipo_de_Rutina.Folio='" + id.ToString() + "'", "").Tipo_de_Rutinas.First();
            Tipo_de_Rutina result = new Tipo_de_Rutina();

            result.Folio       = entity.Folio;
            result.Descripcion = entity.Descripcion;

            return(Request.CreateResponse(HttpStatusCode.OK, result, Configuration.Formatters.JsonFormatter));
        }
Exemple #5
0
        public HttpResponseMessage PutTunnel(Tipo_de_Rutina 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));
        }
Exemple #6
0
        public HttpResponseMessage Put_Datos_Generales(Tipo_de_Rutina varTipo_de_Rutina_Datos_Generales)
        {
            var data = "-1";

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

            return(Request.CreateResponse(HttpStatusCode.OK, data, Configuration.Formatters.JsonFormatter));
        }
Exemple #7
0
        public HttpResponseMessage Tipo_de_RutinaGenerateID()
        {
            Tipo_de_Rutina varTipo_de_Rutina = new Tipo_de_Rutina();
            var            data = "-1";

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

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

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