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

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

            return(Request.CreateResponse(HttpStatusCode.OK, result));
        }
예제 #3
0
        public HttpResponseMessage Get_Datos_Generales(int id)
        {
            Planes_de_Suscripcion entity = this.service.ListaSelAll(1, 1, "Planes_de_Suscripcion.Folio='" + id.ToString() + "'", "").Planes_de_Suscripcions.First();
            Planes_de_Suscripcion result = new Planes_de_Suscripcion();

            result.Folio                = entity.Folio;
            result.Fecha_de_Registro    = entity.Fecha_de_Registro;
            result.Hora_de_Registro     = entity.Hora_de_Registro;
            result.Usuario_que_Registra = entity.Usuario_que_Registra;
            result.Usuario_que_Registra_Spartan_User = entity.Usuario_que_Registra_Spartan_User;
            result.Tipo_de_Beneficiario = entity.Tipo_de_Beneficiario;
            result.Tipo_de_Beneficiario_Tipo_de_Plan_de_Suscripcion = entity.Tipo_de_Beneficiario_Tipo_de_Plan_de_Suscripcion;
            result.Nombre            = entity.Nombre;
            result.Nombre_del_Plan   = entity.Nombre_del_Plan;
            result.Duracion_en_meses = entity.Duracion_en_meses;
            result.Duracion          = entity.Duracion;
            result.Dietas_por_mes    = entity.Dietas_por_mes;
            result.Rutinas_por_mes   = entity.Rutinas_por_mes;
            result.Costo_mensual     = entity.Costo_mensual;
            result.Precio_Final      = entity.Precio_Final;
            result.Estatus           = entity.Estatus;
            result.Estatus_Estatus   = entity.Estatus_Estatus;

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

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

            return(Request.CreateResponse(HttpStatusCode.OK, data, Configuration.Formatters.JsonFormatter));
        }
예제 #6
0
        public HttpResponseMessage Planes_de_SuscripcionGenerateID()
        {
            Planes_de_Suscripcion varPlanes_de_Suscripcion = new Planes_de_Suscripcion();
            var data = "-1";

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

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