Beispiel #1
0
        public HttpResponseMessage Post(MS_Caracteristicas_Platillo varMS_Caracteristicas_Platillo)
        {
            if (ModelState.IsValid)
            {
                var data = "-1";
                try
                {
                    data = Convert.ToString(this.service.Insert(varMS_Caracteristicas_Platillo));
                    var bitacora = BitacoraHelper.GetBitacora(Request, object_id, Convert.ToInt32(data), BitacoraHelper.TypeSql.INSERT, "sp_InsMS_Caracteristicas_Platillo", new JavaScriptSerializer().Serialize(varMS_Caracteristicas_Platillo), true);
                    serviceBitacora.Insert(bitacora);
                }
                catch (ServiceException ex)
                {
                    var bitacora = BitacoraHelper.GetBitacora(Request, object_id, 0, BitacoraHelper.TypeSql.INSERT, "sp_InsMS_Caracteristicas_Platillo", new JavaScriptSerializer().Serialize(varMS_Caracteristicas_Platillo), 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_Caracteristicas_Platillo", new JavaScriptSerializer().Serialize(varMS_Caracteristicas_Platillo), false, errors.ToString());
                serviceBitacora.Insert(bitacora);
                return(Request.CreateResponse(HttpStatusCode.BadRequest, errors));
            }
        }
Beispiel #2
0
        public HttpResponseMessage Delete(int id)
        {
            MS_Caracteristicas_Platillo varMS_Caracteristicas_Platillo = this.service.GetByKey(id, false);
            bool result = false;

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

            return(Request.CreateResponse(HttpStatusCode.OK, result));
        }
Beispiel #3
0
        public ActionResult Post(bool IsNew, MS_Caracteristicas_PlatilloModel varMS_Caracteristicas_Platillo)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    if (!_tokenManager.GenerateToken())
                    {
                        return(Json(null, JsonRequestBehavior.AllowGet));
                    }
                    _IMS_Caracteristicas_PlatilloApiConsumer.SetAuthHeader(_tokenManager.Token);



                    var result = "";
                    var MS_Caracteristicas_PlatilloInfo = new MS_Caracteristicas_Platillo
                    {
                        Folio             = varMS_Caracteristicas_Platillo.Folio
                        , Caracteristicas = varMS_Caracteristicas_Platillo.Caracteristicas
                    };

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

                    return(Json(result, JsonRequestBehavior.AllowGet));
                }
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
            catch (ServiceException ex)
            {
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
        }
Beispiel #4
0
        public HttpResponseMessage Get_Datos_Generales(int id)
        {
            MS_Caracteristicas_Platillo entity = this.service.ListaSelAll(1, 1, "MS_Caracteristicas_Platillo.Folio='" + id.ToString() + "'", "").MS_Caracteristicas_Platillos.First();
            MS_Caracteristicas_Platillo result = new MS_Caracteristicas_Platillo();

            result.Folio           = entity.Folio;
            result.Caracteristicas = entity.Caracteristicas;
            result.Caracteristicas_Caracteristicas_platillo = entity.Caracteristicas_Caracteristicas_platillo;

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

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

            return(Request.CreateResponse(HttpStatusCode.OK, data, Configuration.Formatters.JsonFormatter));
        }
Beispiel #7
0
        public HttpResponseMessage MS_Caracteristicas_PlatilloGenerateID()
        {
            MS_Caracteristicas_Platillo varMS_Caracteristicas_Platillo = new MS_Caracteristicas_Platillo();
            var data = "-1";

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

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

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