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

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

            return(Request.CreateResponse(HttpStatusCode.OK, result));
        }
Ejemplo n.º 3
0
        public ActionResult Post(bool IsNew, MS_Tiempos_de_Comida_PlatillosModel varMS_Tiempos_de_Comida_Platillos)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    if (!_tokenManager.GenerateToken())
                    {
                        return(Json(null, JsonRequestBehavior.AllowGet));
                    }
                    _IMS_Tiempos_de_Comida_PlatillosApiConsumer.SetAuthHeader(_tokenManager.Token);



                    var result = "";
                    var MS_Tiempos_de_Comida_PlatillosInfo = new MS_Tiempos_de_Comida_Platillos
                    {
                        Folio = varMS_Tiempos_de_Comida_Platillos.Folio
                        , Tiempo_de_Comida = varMS_Tiempos_de_Comida_Platillos.Tiempo_de_Comida
                    };

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

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

            result.Folio            = entity.Folio;
            result.Tiempo_de_Comida = entity.Tiempo_de_Comida;
            result.Tiempo_de_Comida_Tiempos_de_Comida = entity.Tiempo_de_Comida_Tiempos_de_Comida;

            return(Request.CreateResponse(HttpStatusCode.OK, result, Configuration.Formatters.JsonFormatter));
        }
        public HttpResponseMessage PutTunnel(MS_Tiempos_de_Comida_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));
        }
        public HttpResponseMessage Put_Datos_Generales(MS_Tiempos_de_Comida_Platillos varMS_Tiempos_de_Comida_Platillos_Datos_Generales)
        {
            var data = "-1";

            try
            {
                data = Convert.ToString(this.service.Update_Datos_Generales(varMS_Tiempos_de_Comida_Platillos_Datos_Generales));
                var bitacora = BitacoraHelper.GetBitacora(Request, object_id, varMS_Tiempos_de_Comida_Platillos_Datos_Generales.Folio, BitacoraHelper.TypeSql.UPDATE, "sp_UpdMS_Tiempos_de_Comida_Platillos", new JavaScriptSerializer().Serialize(varMS_Tiempos_de_Comida_Platillos_Datos_Generales), true);
                serviceBitacora.Insert(bitacora);
            }
            catch (ServiceException ex)
            {
                var bitacora = BitacoraHelper.GetBitacora(Request, object_id, varMS_Tiempos_de_Comida_Platillos_Datos_Generales.Folio, BitacoraHelper.TypeSql.UPDATE, "sp_UpdMS_Tiempos_de_Comida_Platillos", new JavaScriptSerializer().Serialize(varMS_Tiempos_de_Comida_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));
        }
        public HttpResponseMessage MS_Tiempos_de_Comida_PlatillosGenerateID()
        {
            MS_Tiempos_de_Comida_Platillos varMS_Tiempos_de_Comida_Platillos = new MS_Tiempos_de_Comida_Platillos();
            var data = "-1";

            try
            {
                data = Convert.ToString(this.service.Insert(varMS_Tiempos_de_Comida_Platillos));
                var bitacora = BitacoraHelper.GetBitacora(Request, object_id, Convert.ToInt32(data), BitacoraHelper.TypeSql.INSERT, "sp_MS_Tiempos_de_Comida_PlatillosGenerateID", new JavaScriptSerializer().Serialize(varMS_Tiempos_de_Comida_Platillos), true);
                serviceBitacora.Insert(bitacora);
            }
            catch (ServiceException ex)
            {
                var bitacora = BitacoraHelper.GetBitacora(Request, object_id, 0, BitacoraHelper.TypeSql.INSERT, "sp_MS_Tiempos_de_Comida_PlatillosGenerateID", new JavaScriptSerializer().Serialize(varMS_Tiempos_de_Comida_Platillos), 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_Tiempos_de_Comida_PlatillosApiConsumer.SetAuthHeader(_tokenManager.Token);

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