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)); }
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)); }
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(); }
//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); }
// GET: RedSocial/Create public ActionResult Create(int?pagina) { ViewBag.Pagina = (pagina ?? 1); RedSocial bdRedSocial = new RedSocial(); bdRedSocial.NoPost = 1; return(View(bdRedSocial)); }
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); }
public async Task <ActionResult> DeleteConfirmed(int id) { RedSocial redSocial = await db.RedSocials.FindAsync(id); db.RedSocials.Remove(redSocial); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public async Task <RedSocial> GetRedSocial(int id) { RedSocial redSocial = await db.RedSocials.FindAsync(id); if (redSocial == null) { return(null); } return(redSocial); }
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)); }
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 }); }
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)); }
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 })); }
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); }
// 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)); }
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)); }
// 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)); }
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"); } }
// 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)); }
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); }
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)); }
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(); }
//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); }
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); }
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()); }
/// <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); }
public int insertarRedSocial(RedSocial RS) { return(ars.insertarRedSocial(RS)); }
public int editarRedSocial(RedSocial RS) { return(ars.editarRedSocial(RS)); }
/// <summary> /// Crea una nueva red social /// </summary> /// <param name="pRedSocial">Red social a crear</param> public void NuevaRedSocial(RedSocial pRedSocial) { (ModeloFachada.GetInstancia()).CrearRedSocial(pRedSocial); }