Esempio n. 1
0
        public async Task <IHttpActionResult> PutRedSocial(int id, RedSocial redSocial)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != redSocial.RedSocialId)
            {
                return(BadRequest());
            }

            db.Entry(redSocial).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!RedSocialExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Esempio n. 2
0
        public async Task <IActionResult> EditarRedesSociales(int id, [Bind("IdRedSocial,Email,Whatsapp,Twitter,Facebook,Instagram")] RedSocial redSocial)
        {
            if (id != redSocial.IdRedSocial)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(redSocial);

                    await _context.SaveChangesAsync();

                    return(RedirectToAction("Index", "Vendedores"));
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!(_app.TiendaExiste(redSocial.IdRedSocial)))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
            }
            return(View(redSocial));
        }
Esempio n. 3
0
 public int AgresoresRedesSociales_Insertar(RedSocial redSocial, Agresor agresor)
 {
     return(Convert.ToInt32(DevolverEscalar("AgresoresRedesSociales_Insertar",
                                            new SqlParameter("@IdAgresor", agresor.Id),
                                            new SqlParameter("@IdTipoRedSocial", redSocial.Tipo.Id),
                                            new SqlParameter("@Nombre", redSocial.Nombre))));
 }
        /// <summary>
        /// Elimina la red social indicada del usuario
        /// </summary>
        /// <param name="pIdRS">Id de la red social que se quiere eliminar</param>
        public void EliminarRedSocial(RedSocial pUnaRedSocial)
        {
            RedSocial iRedSocial = iUnidadDeTrabajo.RepositorioRedSocial.GetByID(pUnaRedSocial.RedSocialId);

            iUnidadDeTrabajo.RepositorioRedSocial.Delete(iRedSocial);
            iUnidadDeTrabajo.Save();
        }
Esempio n. 5
0
        //DEFINICIÓN DEL MÉTODO INSERTAR REDSOCIAL
        public int insertarRedSocial(RedSocial RS)
        {
            try
            {
                SqlConnection cnx = cn.conectar();

                cm = new SqlCommand("RedesSociales", cnx);
                cm.Parameters.AddWithValue("@b", 1);
                cm.Parameters.AddWithValue("@idRedSocial", "");
                cm.Parameters.AddWithValue("@NombreR", RS.NombreR);
                cm.Parameters.AddWithValue("@idCliente", "");

                cm.CommandType = CommandType.StoredProcedure;
                cnx.Open();
                cm.ExecuteNonQuery();
                indicador = 1;
            }
            catch (Exception e)
            {
                e.Message.ToString();
                indicador = 0;
            }
            finally
            {
                cm.Connection.Close();
            }
            return(indicador);
        }
Esempio n. 6
0
        // GET: RedSocial/Create
        public ActionResult Create(int?pagina)
        {
            ViewBag.Pagina = (pagina ?? 1);
            RedSocial bdRedSocial = new RedSocial();

            bdRedSocial.NoPost = 1;
            return(View(bdRedSocial));
        }
Esempio n. 7
0
        private RedSocial FilaARedSocial(DataRow fila)
        {
            var redSocial = new RedSocial();

            redSocial.Id     = (int)fila["IdAgresorRedSocial"];
            redSocial.Tipo   = repositorioTiposRedesSociales.DevolverPorId((byte)fila["IdTipoRedSocial"]);
            redSocial.Nombre = (string)fila["Nombre"];
            return(redSocial);
        }
Esempio n. 8
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            RedSocial redSocial = await db.RedSocials.FindAsync(id);

            db.RedSocials.Remove(redSocial);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Esempio n. 9
0
        public async Task <RedSocial> GetRedSocial(int id)
        {
            RedSocial redSocial = await db.RedSocials.FindAsync(id);

            if (redSocial == null)
            {
                return(null);
            }

            return(redSocial);
        }
Esempio n. 10
0
        public async Task <ActionResult> Edit([Bind(Include = "RedSocialId,Name")] RedSocial redSocial)
        {
            if (ModelState.IsValid)
            {
                db.Entry(redSocial).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(redSocial));
        }
Esempio n. 11
0
        public async Task <IHttpActionResult> PostRedSocial(RedSocial redSocial)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.RedSocials.Add(redSocial);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = redSocial.RedSocialId }, redSocial));
        }
        private void CollectionDeRedesSociales_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            RedSocial redSocial = CollectionDeRedesSociales.SelectedItem as RedSocial;

            Browser.OpenAsync(redSocial.URL, new BrowserLaunchOptions
            {
                LaunchMode            = BrowserLaunchMode.SystemPreferred,
                TitleMode             = BrowserTitleMode.Show,
                PreferredToolbarColor = Color.AliceBlue,
                PreferredControlColor = Color.Violet
            });
        }
Esempio n. 13
0
        public async Task <ActionResult> Create([Bind(Include = "RedSocialId,Name")] RedSocial redSocial)
        {
            if (ModelState.IsValid)
            {
                db.RedSocials.Add(redSocial);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(redSocial));
        }
Esempio n. 14
0
        public ActionResult DeleteConfirmed(int id, int?pagina)
        {
            ViewBag.Pagina = (pagina ?? 1);
            RedSocial bdRedSocial = db.RedSocial.Find(id);

            if (bdRedSocial.PostEnLaRedSocial.Count == 0)
            {
                db.RedSocial.Remove(bdRedSocial);
                db.SaveChanges();
            }
            return(RedirectToAction("Index", "RedSocial", new { pagina = ViewBag.Pagina }));
        }
Esempio n. 15
0
        private JArray FeedsInstagram(RedSocial pBdRed)
        {
            JArray jaResponse = new JArray();
            List <SocialNetPost> lInstaPosts = new List <SocialNetPost>();
            HttpWebRequest       request     = (HttpWebRequest)HttpWebRequest.Create("https://api.instagram.com/v1/users/" +
                                                                                     pBdRed.APPId + "/media/recent?count=" + pBdRed.NoPost + "&access_token=" + pBdRed.APIKey);

            request.Method = "GET";
            String json = String.Empty;

            using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
            {
                Stream       dataStream = response.GetResponseStream();
                StreamReader reader     = new StreamReader(dataStream);
                json = reader.ReadToEnd();
                reader.Close();
                dataStream.Close();
            }
            dynamic dyn = JsonConvert.DeserializeObject(json);

            foreach (var data in dyn.data)
            {
                SocialNetPost instapost = new SocialNetPost();
                instapost.ID    = Convert.ToString(data.id);
                instapost.URL   = Convert.ToString(data.link);
                instapost.Thumb = Convert.ToString(data.images.thumbnail.url);
                instapost.Date  = UnixTimeStampToDateTime((double)data.created_time);
                instapost.Title = "";
                if (data.caption != null)
                {
                    instapost.Description = Convert.ToString(data.caption.text);
                }
                instapost.Name = "instagram";
                lInstaPosts.Add(instapost);
                lAllPosts.Add(instapost);
            }
            foreach (var Instapost in lInstaPosts.OrderByDescending(s => s.Date))
            {
                JObject joTweet =
                    new JObject(
                        new JProperty("url", Instapost.URL),
                        new JProperty("thumbnail", Instapost.Thumb),
                        new JProperty("day", Instapost.Date.ToString("dd", CultureInfo.InvariantCulture)),
                        new JProperty("month", Instapost.Date.ToString("MMM", CultureInfo.CreateSpecificCulture("es-MX")).ToUpper()),
                        new JProperty("year", Instapost.Date.ToString("yyyy", CultureInfo.InvariantCulture)),
                        new JProperty("title", Instapost.Title),
                        new JProperty("description", Instapost.Description)
                        );
                jaResponse.Add(joTweet);
            }
            return(jaResponse);
        }
Esempio n. 16
0
        // GET: RedSocials/Delete/5
        public async Task <ActionResult> Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            RedSocial redSocial = await db.RedSocials.FindAsync(id);

            if (redSocial == null)
            {
                return(HttpNotFound());
            }
            return(View(redSocial));
        }
Esempio n. 17
0
        public async Task <IHttpActionResult> DeleteRedSocial(int id)
        {
            RedSocial redSocial = await db.RedSocials.FindAsync(id);

            if (redSocial == null)
            {
                return(NotFound());
            }

            db.RedSocials.Remove(redSocial);
            await db.SaveChangesAsync();

            return(Ok(redSocial));
        }
Esempio n. 18
0
        // GET: RedSocial/Details/5
        public ActionResult Details(int?id, int?pagina)
        {
            ViewBag.Pagina = (pagina ?? 1);
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            RedSocial bdRedSocial = db.RedSocial.Find(id);

            if (bdRedSocial == null)
            {
                return(HttpNotFound());
            }
            return(View(bdRedSocial));
        }
Esempio n. 19
0
        private void buttonGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                if (buttonGuardar.Text == "Guardar")
                {
                    RedSocial objetoRedSocial = new RedSocial();
                    objetoRedSocial.NombreR   = textBoxNombreR.Text;
                    objetoRedSocial.idCliente = Convert.ToInt32(textBoxIdCliente.Text);

                    if (logicaNRS.insertarRedSocial(objetoRedSocial) > 0)
                    {
                        MessageBox.Show("Agregado con éxito");
                        dataGridViewRedSocial.DataSource = logicaNRS.listarRedSocial();
                        textBoxNombreR.Text      = "";
                        textBoxIdCliente.Text    = "";
                        tabRedSocial.SelectedTab = tabPage2; //Consultar
                    }
                    else
                    {
                        MessageBox.Show("Error al agregar Red Social");
                    }
                }
                if (buttonGuardar.Text == "Actualizar")
                {
                    RedSocial objetoRedSocial = new RedSocial();
                    objetoRedSocial.idRedSocial = Convert.ToInt32(textBoxId.Text);
                    objetoRedSocial.NombreR     = textBoxNombreR.Text;
                    objetoRedSocial.idCliente   = Convert.ToInt32(textBoxIdCliente.Text);

                    if (logicaNRS.editarRedSocial(objetoRedSocial) > 0)
                    {
                        MessageBox.Show("Actualizado con éxito");
                        dataGridViewRedSocial.DataSource = logicaNRS.listarRedSocial();
                        textBoxNombreR.Text      = "";
                        textBoxIdCliente.Text    = "";
                        tabRedSocial.SelectedTab = tabPage2;
                    }
                    else
                    {
                        MessageBox.Show("Error al actualizar Red Social");
                    }
                    buttonGuardar.Text = "Guardar";
                }
            }
            catch
            { MessageBox.Show("ERROR"); }
        }
Esempio n. 20
0
        // GET: ContenidoEstatico/Create
        public ActionResult Create(int?redsocial, int?pagina)
        {
            if (redsocial == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            RedSocial bdRedSocial = db.RedSocial.Find(redsocial);

            if (bdRedSocial == null)
            {
                return(HttpNotFound());
            }
            ViewBag.Pagina = (pagina ?? 1);
            ContenidoEstatico bdContenidoEstatico = new ContenidoEstatico();

            bdContenidoEstatico.RedSocialID = Convert.ToInt32(redsocial);
            return(View(bdContenidoEstatico));
        }
Esempio n. 21
0
        private JArray CreateJsonFeedsSocialNet(RedSocial pBdRed)
        {
            JArray jaResponse = new JArray();

            switch (pBdRed.Nombre.ToLower().Trim())
            {
            case "youtube":
                jaResponse = FeedsYoutube(pBdRed);
                break;

            case "twitter":
                jaResponse = FeedsTwitter(pBdRed);
                break;

            case "instagram":
                jaResponse = FeedsInstagram(pBdRed);
                break;
            }
            return(jaResponse);
        }
Esempio n. 22
0
 public ActionResult Create(int?pagina, [Bind(Include = "ID,Nombre,Identificador,URL,APPId,APIKey,NoPost")] RedSocial redSocial)
 {
     ViewBag.Pagina = (pagina ?? 1);
     if (ModelState.IsValid)
     {
         if (db.RedSocial.Any(x => x.Nombre.Trim().ToUpper() == redSocial.Nombre.Trim().ToUpper()))
         {
             ModelState.AddModelError("Nombre", "Ya existe una Red Social con ese Nombre");
         }
         else if (db.RedSocial.Any(x => x.Identificador.Trim().ToUpper() == redSocial.Identificador.Trim().ToUpper()))
         {
             ModelState.AddModelError("Identificador", "Ya existe una Red Social con ese Identificador");
         }
         else
         {
             db.RedSocial.Add(redSocial);
             db.SaveChanges();
             return(RedirectToAction("Index", "RedSocial", new { sSearchString = redSocial.Nombre }));
         }
     }
     return(View(redSocial));
 }
Esempio n. 23
0
        protected void btnAceptarNuevaRedSocial_Click(object sender, EventArgs e)
        {
            int     id      = Convert.ToInt32(hdnIdAgresor.Value);
            Agresor agresor = servicioWeb.DevolverAgresorPorId(id, true, true, true);

            RedSocial redSocial = new RedSocial();

            redSocial.Tipo        = new TipoRedSocial();
            redSocial.Tipo.Id     = Convert.ToByte(ddlTipoRedSocial.SelectedValue);
            redSocial.Tipo.Nombre = ddlTipoRedSocial.SelectedItem.Text;
            redSocial.Nombre      = txtNombreRedSocial.Text;

            var listaRedesSociales = agresor.RedesSociales.ToList();

            listaRedesSociales.Add(redSocial);
            agresor.RedesSociales = listaRedesSociales.ToArray();

            servicioWeb.ModificarAgresor(agresor);

            grdRedesSociales.DataSource = (servicioWeb.DevolverAgresorPorId(id, false, false, true)).RedesSociales;
            grdRedesSociales.DataBind();
        }
Esempio n. 24
0
        //DEFINICIÓN DEL MÉTODO LISTAR REDSOCIAL
        public List <RedSocial> listarRedSocial()
        {
            try
            {
                SqlConnection cnx = cn.conectar();


                cm = new SqlCommand("RedesSociales", cnx);
                cm.Parameters.AddWithValue("@b", 3);
                cm.Parameters.AddWithValue("@idRedSocial", "");
                cm.Parameters.AddWithValue("@NombreR", "");
                cm.Parameters.AddWithValue("@idCliente", "");

                cm.CommandType = CommandType.StoredProcedure;
                cnx.Open();
                dr             = cm.ExecuteReader();
                listaRedSocial = new List <RedSocial>();

                while (dr.Read())
                {
                    RedSocial r = new RedSocial();
                    r.idRedSocial = Convert.ToInt32(dr["idRedSocial"].ToString());
                    r.NombreR     = dr["NombreR"].ToString();
                    r.idCliente   = Convert.ToInt32(dr["idCliente"].ToString());
                    listaRedSocial.Add(r);
                }
            }
            catch (Exception e)
            {
                e.Message.ToString();
                listaRedSocial = null;
            }
            finally
            {
                cm.Connection.Close();
            }
            return(listaRedSocial);
        }
Esempio n. 25
0
        private JArray FeedsTwitter(RedSocial pBdRed)
        {
            JArray jaResponse = new JArray();
            List <SocialNetPost> lTweetPosts = new List <SocialNetPost>();
            var     twitter  = new Twitter(pBdRed.APPId, pBdRed.APIKey, "150706984-SLW2aTZi9xzQ2Jf7lnCM7CuOsojfiKAo9aI2ME2z", "xbvbnZ72usfVen5cnk3OOiajEp78bNCeaU5AZi0GyoQVH");
            var     response = twitter.GetTweets(pBdRed.Identificador.Replace("@", "").ToLower(), pBdRed.NoPost);
            dynamic timeline = System.Web.Helpers.Json.Decode(response);

            foreach (var tweet in timeline)
            {
                SocialNetPost twett = new SocialNetPost();
                twett.ID          = tweet["id_str"].ToString();
                twett.URL         = "https://twitter.com/" + pBdRed.Identificador.Replace("@", "").ToLower() + "/status/" + tweet["id_str"].ToString();
                twett.Thumb       = "";
                twett.Date        = DateTime.ParseExact(tweet["created_at"].ToString(), "ddd MMM dd HH:mm:ss zzz yyyy", CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal);
                twett.Title       = "";
                twett.Description = tweet["text"].ToString();
                twett.Name        = "twitter";
                lTweetPosts.Add(twett);
                lAllPosts.Add(twett);
            }
            foreach (var Tweet in lTweetPosts.OrderByDescending(s => s.Date))
            {
                JObject joTweet =
                    new JObject(
                        new JProperty("url", Tweet.URL),
                        new JProperty("thumbnail", Tweet.Thumb),
                        new JProperty("day", Tweet.Date.ToString("dd", CultureInfo.InvariantCulture)),
                        new JProperty("month", Tweet.Date.ToString("MMM", CultureInfo.CreateSpecificCulture("es-MX")).ToUpper()),
                        new JProperty("year", Tweet.Date.ToString("yyyy", CultureInfo.InvariantCulture)),
                        new JProperty("title", Tweet.Title),
                        new JProperty("description", Tweet.Description)
                        );
                jaResponse.Add(joTweet);
            }
            return(jaResponse);
        }
Esempio n. 26
0
        public async Task <IActionResult> OnPostAsync(string returnUrl = null)
        {
            returnUrl      = returnUrl ?? Url.Content("~/");
            ExternalLogins = (await _signInManager.GetExternalAuthenticationSchemesAsync()).ToList();
            if (ModelState.IsValid)
            {
                var user = new Vendedor {
                    UserName = Input.Email, Email = Input.Email
                };
                var result = await _userManager.CreateAsync(user, Input.Password);

                if (result.Succeeded)
                {
                    _logger.LogInformation("User created a new account with password.");



                    var usuario = await _context.Vendedores.FirstOrDefaultAsync(v => v.Email == Input.Email);


                    var redSocialNueva = new RedSocial {
                        Email = Input.Email, Facebook = "face", Instagram = "insta", Twitter = "twtt", Whatsapp = "22222"
                    };
                    _context.RedesSociales.Add(redSocialNueva);
                    await _context.SaveChangesAsync();



                    var redSocialBD = await _context.RedesSociales.FirstOrDefaultAsync(r => r.Email == Input.Email);


                    var nombreTienda = "Tienda de " + Input.Email;

                    var tiendaNueva = new Tienda {
                        NombreTienda = nombreTienda, IdRedSocial = redSocialBD.IdRedSocial, RedSocial = redSocialBD, Publicada = true
                    };
                    _context.Tiendas.Add(tiendaNueva);
                    await _context.SaveChangesAsync();

                    var tiendaBD = await _context.Tiendas.FirstOrDefaultAsync(t => t.IdRedSocial == redSocialBD.IdRedSocial);

                    var productoNuevo1 = new Producto()
                    {
                        NombreProducto = "Prod de Ejemplo1", DescripcionProducto = "Descripción Ejemplo", PrecioProducto = 99.99, IdTienda = tiendaBD.IdTienda
                    };
                    _context.Productos.Add(productoNuevo1);
                    await _context.SaveChangesAsync();

                    var productoNuevo2 = new Producto()
                    {
                        NombreProducto = "Prod de Ejemplo2", DescripcionProducto = "Descripción Ejemplo", PrecioProducto = 99.99, IdTienda = tiendaBD.IdTienda
                    };
                    _context.Productos.Add(productoNuevo2);
                    await _context.SaveChangesAsync();



                    usuario.IdTienda = tiendaBD.IdTienda;
                    usuario.Tienda   = tiendaBD;
                    await _context.SaveChangesAsync();



                    var tiendaDeUsuario = await _context.Tiendas.FirstOrDefaultAsync(t => t.IdTienda == usuario.IdTienda);

                    var redSocialDeTiendaDeUsuario = await _context.RedesSociales.FirstOrDefaultAsync(r => r.IdRedSocial == tiendaDeUsuario.IdRedSocial);



                    var code = await _userManager.GenerateEmailConfirmationTokenAsync(user);

                    code = WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes(code));
                    var callbackUrl = Url.Page(
                        "/Account/ConfirmEmail",
                        pageHandler: null,
                        values: new { area = "Identity", userId = user.Id, code = code, returnUrl = returnUrl },
                        protocol: Request.Scheme);

                    await _emailSender.SendEmailAsync(Input.Email, "Confirm your email",
                                                      $"Please confirm your account by <a href='{HtmlEncoder.Default.Encode(callbackUrl)}'>clicking here</a>.");

                    if (_userManager.Options.SignIn.RequireConfirmedAccount)
                    {
                        return(RedirectToPage("RegisterConfirmation", new { email = Input.Email, returnUrl = returnUrl }));
                    }
                    else
                    {
                        await _signInManager.SignInAsync(user, isPersistent : false);

                        return(LocalRedirect(returnUrl));
                    }
                }
                foreach (var error in result.Errors)
                {
                    ModelState.AddModelError(string.Empty, error.Description);
                }
            }

            // If we got this far, something failed, redisplay form
            return(Page());
        }
Esempio n. 27
0
        /// <summary>
        /// Elimina la red social indicada del usuario
        /// </summary>
        /// <param name="pIdRS">Id de la red social que se quiere eliminar</param>
        public void EliminarRedSocial(int pIdRS)
        {
            RedSocial red = ModeloFachada.GetInstancia().BuscarRedSocial(pIdRS);

            ModeloFachada.GetInstancia().EliminarRedSocial(red);
        }
Esempio n. 28
0
 public int insertarRedSocial(RedSocial RS)
 {
     return(ars.insertarRedSocial(RS));
 }
Esempio n. 29
0
 public int editarRedSocial(RedSocial RS)
 {
     return(ars.editarRedSocial(RS));
 }
Esempio n. 30
0
 /// <summary>
 /// Crea una nueva red social
 /// </summary>
 /// <param name="pRedSocial">Red social a crear</param>
 public void NuevaRedSocial(RedSocial pRedSocial)
 {
     (ModeloFachada.GetInstancia()).CrearRedSocial(pRedSocial);
 }