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

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

            return(Request.CreateResponse(HttpStatusCode.OK, result));
        }
        public HttpResponseMessage PutTunnel(Detalle_Contactos_Empresa 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(Detalle_Contactos_Empresa varDetalle_Contactos_Empresa_Datos_Generales)
        {
            var data = "-1";

            try
            {
                data = Convert.ToString(this.service.Update_Datos_Generales(varDetalle_Contactos_Empresa_Datos_Generales));
                var bitacora = BitacoraHelper.GetBitacora(Request, object_id, varDetalle_Contactos_Empresa_Datos_Generales.Folio, BitacoraHelper.TypeSql.UPDATE, "sp_UpdDetalle_Contactos_Empresa", new JavaScriptSerializer().Serialize(varDetalle_Contactos_Empresa_Datos_Generales), true);
                serviceBitacora.Insert(bitacora);
            }
            catch (ServiceException ex)
            {
                var bitacora = BitacoraHelper.GetBitacora(Request, object_id, varDetalle_Contactos_Empresa_Datos_Generales.Folio, BitacoraHelper.TypeSql.UPDATE, "sp_UpdDetalle_Contactos_Empresa", new JavaScriptSerializer().Serialize(varDetalle_Contactos_Empresa_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 ActionResult Post(bool IsNew, Detalle_Contactos_EmpresaModel varDetalle_Contactos_Empresa)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    if (!_tokenManager.GenerateToken())
                    {
                        return(Json(null, JsonRequestBehavior.AllowGet));
                    }
                    _IDetalle_Contactos_EmpresaApiConsumer.SetAuthHeader(_tokenManager.Token);



                    var result = "";
                    var Detalle_Contactos_EmpresaInfo = new Detalle_Contactos_Empresa
                    {
                        Folio                = varDetalle_Contactos_Empresa.Folio
                        , Nombre_completo    = varDetalle_Contactos_Empresa.Nombre_completo
                        , Correo             = varDetalle_Contactos_Empresa.Correo
                        , Telefono           = varDetalle_Contactos_Empresa.Telefono
                        , Contacto_Principal = varDetalle_Contactos_Empresa.Contacto_Principal
                        , Area               = varDetalle_Contactos_Empresa.Area
                        , Acceso_al_Sistema  = varDetalle_Contactos_Empresa.Acceso_al_Sistema
                        , Nombre_de_usuario  = varDetalle_Contactos_Empresa.Nombre_de_usuario
                        , Recibe_Alertas     = varDetalle_Contactos_Empresa.Recibe_Alertas
                        , Estatus            = varDetalle_Contactos_Empresa.Estatus
                        , Folio_Usuario      = varDetalle_Contactos_Empresa.Folio_Usuario
                    };

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

                    return(Json(result, JsonRequestBehavior.AllowGet));
                }
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
            catch (ServiceException ex)
            {
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
        }
        public HttpResponseMessage Detalle_Contactos_EmpresaGenerateID()
        {
            Detalle_Contactos_Empresa varDetalle_Contactos_Empresa = new Detalle_Contactos_Empresa();
            var data = "-1";

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

            return(Request.CreateResponse(HttpStatusCode.OK, data, Configuration.Formatters.JsonFormatter));
        }
Ejemplo n.º 7
0
        public HttpResponseMessage Get_Datos_Generales(int id)
        {
            Detalle_Contactos_Empresa entity = this.service.ListaSelAll(1, 1, "Detalle_Contactos_Empresa.Folio='" + id.ToString() + "'", "").Detalle_Contactos_Empresas.First();
            Detalle_Contactos_Empresa result = new Detalle_Contactos_Empresa();

            result.Folio              = entity.Folio;
            result.Nombre_completo    = entity.Nombre_completo;
            result.Correo             = entity.Correo;
            result.Telefono           = entity.Telefono;
            result.Contacto_Principal = entity.Contacto_Principal;
            result.Area = entity.Area;
            result.Area_areas_Empresas = entity.Area_areas_Empresas;
            result.Acceso_al_Sistema   = entity.Acceso_al_Sistema;
            result.Nombre_de_usuario   = entity.Nombre_de_usuario;
            result.Recibe_Alertas      = entity.Recibe_Alertas;
            result.Estatus             = entity.Estatus;
            result.Estatus_Estatus     = entity.Estatus_Estatus;

            return(Request.CreateResponse(HttpStatusCode.OK, result, Configuration.Formatters.JsonFormatter));
        }
Ejemplo n.º 8
0
        public ActionResult Delete(int id)
        {
            try
            {
                if (!_tokenManager.GenerateToken())
                {
                    return(Json(null, JsonRequestBehavior.AllowGet));
                }
                _IDetalle_Contactos_EmpresaApiConsumer.SetAuthHeader(_tokenManager.Token);

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