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

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

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

            result.Folio       = entity.Folio;
            result.Descripcion = entity.Descripcion;

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

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

            return(Request.CreateResponse(HttpStatusCode.OK, data, Configuration.Formatters.JsonFormatter));
        }
Example #6
0
        public HttpResponseMessage Parentescos_EmpleadosGenerateID()
        {
            Parentescos_Empleados varParentescos_Empleados = new Parentescos_Empleados();
            var data = "-1";

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

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