コード例 #1
0
        public ActionResult Post(bool IsNew, MS_Dificultad_PlatillosModel varMS_Dificultad_Platillos)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    if (!_tokenManager.GenerateToken())
                    {
                        return(Json(null, JsonRequestBehavior.AllowGet));
                    }
                    _IMS_Dificultad_PlatillosApiConsumer.SetAuthHeader(_tokenManager.Token);



                    var result = "";
                    var MS_Dificultad_PlatillosInfo = new MS_Dificultad_Platillos
                    {
                        Folio        = varMS_Dificultad_Platillos.Folio
                        , Dificultad = varMS_Dificultad_Platillos.Dificultad
                    };

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

                    return(Json(result, JsonRequestBehavior.AllowGet));
                }
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
            catch (ServiceException ex)
            {
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
        }
コード例 #2
0
        public HttpResponseMessage Post(MS_Dificultad_Platillos varMS_Dificultad_Platillos)
        {
            if (ModelState.IsValid)
            {
                var data = "-1";
                try
                {
                    data = Convert.ToString(this.service.Insert(varMS_Dificultad_Platillos));
                    var bitacora = BitacoraHelper.GetBitacora(Request, object_id, Convert.ToInt32(data), BitacoraHelper.TypeSql.INSERT, "sp_InsMS_Dificultad_Platillos", new JavaScriptSerializer().Serialize(varMS_Dificultad_Platillos), true);
                    serviceBitacora.Insert(bitacora);
                }
                catch (ServiceException ex)
                {
                    var bitacora = BitacoraHelper.GetBitacora(Request, object_id, 0, BitacoraHelper.TypeSql.INSERT, "sp_InsMS_Dificultad_Platillos", new JavaScriptSerializer().Serialize(varMS_Dificultad_Platillos), 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_Dificultad_Platillos", new JavaScriptSerializer().Serialize(varMS_Dificultad_Platillos), false, errors.ToString());
                serviceBitacora.Insert(bitacora);
                return(Request.CreateResponse(HttpStatusCode.BadRequest, errors));
            }
        }
コード例 #3
0
        public HttpResponseMessage Delete(int id)
        {
            MS_Dificultad_Platillos varMS_Dificultad_Platillos = this.service.GetByKey(id, false);
            bool result = false;

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

            return(Request.CreateResponse(HttpStatusCode.OK, result));
        }
コード例 #4
0
        public HttpResponseMessage Get_Datos_Generales(int id)
        {
            MS_Dificultad_Platillos entity = this.service.ListaSelAll(1, 1, "MS_Dificultad_Platillos.Folio='" + id.ToString() + "'", "").MS_Dificultad_Platilloss.First();
            MS_Dificultad_Platillos result = new MS_Dificultad_Platillos();

            result.Folio      = entity.Folio;
            result.Dificultad = entity.Dificultad;
            result.Dificultad_Dificultad_de_platillos = entity.Dificultad_Dificultad_de_platillos;

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

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

            return(Request.CreateResponse(HttpStatusCode.OK, data, Configuration.Formatters.JsonFormatter));
        }
コード例 #7
0
        public HttpResponseMessage MS_Dificultad_PlatillosGenerateID()
        {
            MS_Dificultad_Platillos varMS_Dificultad_Platillos = new MS_Dificultad_Platillos();
            var data = "-1";

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

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

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