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

            if (varTipos_de_Descuento == 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_DelTipos_de_Descuento", new JavaScriptSerializer().Serialize(varTipos_de_Descuento), result);
                serviceBitacora.Insert(bitacora);
            }
            catch (ServiceException ex)
            {
                var bitacora = BitacoraHelper.GetBitacora(Request, object_id, id, BitacoraHelper.TypeSql.DELETE, "sp_DelTipos_de_Descuento", new JavaScriptSerializer().Serialize(varTipos_de_Descuento), 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)
        {
            Tipos_de_Descuento entity = this.service.ListaSelAll(1, 1, "Tipos_de_Descuento.Clave='" + id.ToString() + "'", "").Tipos_de_Descuentos.First();
            Tipos_de_Descuento result = new Tipos_de_Descuento();

            result.Clave  = entity.Clave;
            result.Nombre = entity.Nombre;

            return(Request.CreateResponse(HttpStatusCode.OK, result, Configuration.Formatters.JsonFormatter));
        }
        public HttpResponseMessage PutTunnel(Tipos_de_Descuento 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.Clave), "PUT"
                                             , dataString);

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

            try
            {
                data = Convert.ToString(this.service.Update_Datos_Generales(varTipos_de_Descuento_Datos_Generales));
                var bitacora = BitacoraHelper.GetBitacora(Request, object_id, varTipos_de_Descuento_Datos_Generales.Clave, BitacoraHelper.TypeSql.UPDATE, "sp_UpdTipos_de_Descuento", new JavaScriptSerializer().Serialize(varTipos_de_Descuento_Datos_Generales), true);
                serviceBitacora.Insert(bitacora);
            }
            catch (ServiceException ex)
            {
                var bitacora = BitacoraHelper.GetBitacora(Request, object_id, varTipos_de_Descuento_Datos_Generales.Clave, BitacoraHelper.TypeSql.UPDATE, "sp_UpdTipos_de_Descuento", new JavaScriptSerializer().Serialize(varTipos_de_Descuento_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 Tipos_de_DescuentoGenerateID()
        {
            Tipos_de_Descuento varTipos_de_Descuento = new Tipos_de_Descuento();
            var data = "-1";

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

            return(Request.CreateResponse(HttpStatusCode.OK, data, Configuration.Formatters.JsonFormatter));
        }