Ejemplo n.º 1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            FacebookGraph fbUser;
            if (StateManager.IsAuthenticated(out fbUser))
            {
                var user = new UsersService().GetUserByExternalId(fbUser.Id);
                if (user != null)
                {
                    var code = Guid.NewGuid().ToString();
                    var site = new Sites()
                    {
                        flickr_username = txtFlickrUsername.Text,
                        title = txtTitle.Text,
                        site_type = Convert.ToInt32(txtType.Text),
                        verification_code = code
                    };
                    new SitesService().Save(user.id, txtEmail.Text, site);

                    this.pnlForm.Visible = false;
                    this.pnlMsg.Visible = true;
                    this.lblMsg.Text = "El sitio se ha creado satisfactoriamente, accedé ya al mismo:";

                    var shortUrl = GoogleConsumer.ShortenUrl(PageFlowExtensions.GetDefaultPageUrl().OriginalString + "?icode=" + code);

                    this.hlLink.NavigateUrl = shortUrl;
                    this.hlLink.Text = shortUrl;
                }
            }
        }
Ejemplo n.º 2
0
        public bool Exists(int siteId, out Sites site)
        {
            site = null;
            var query = from p in db.Sites
                        where p.id == siteId
                        select p;

            if (query != null) site = query.First();

            return query.Count() > 0;
        }
Ejemplo n.º 3
0
        public bool Exists(string code, out Sites site)
        {
            site = null;
            var query = from p in db.Sites
                        where p.verification_code == code
                        select p;

            if (query != null) site = query.FirstOrDefault();

            return query.Count() > 0;
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Create a new Sites object.
 /// </summary>
 /// <param name="id">Initial value of the id property.</param>
 /// <param name="title">Initial value of the title property.</param>
 /// <param name="site_type">Initial value of the site_type property.</param>
 /// <param name="flickr_username">Initial value of the flickr_username property.</param>
 /// <param name="verification_code">Initial value of the verification_code property.</param>
 /// <param name="date_created">Initial value of the date_created property.</param>
 public static Sites CreateSites(global::System.Int32 id, global::System.String title, global::System.Int32 site_type, global::System.String flickr_username, global::System.String verification_code, global::System.DateTime date_created)
 {
     Sites sites = new Sites();
     sites.id = id;
     sites.title = title;
     sites.site_type = site_type;
     sites.flickr_username = flickr_username;
     sites.verification_code = verification_code;
     sites.date_created = date_created;
     return sites;
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Sites EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToSites(Sites sites)
 {
     base.AddObject("Sites", sites);
 }
Ejemplo n.º 6
0
        public ActionResult Create(SiteModel sitemodel)
        {
            if (ModelState.IsValid)
            {
                var id = Convert.ToInt32(StateManager.GetCurrentUser());
                var site = new Sites()
                {
                    flickr_username = sitemodel.FlickrUserName,
                    title = sitemodel.Title,
                    site_type = sitemodel.SiteType,
                    verification_code = Guid.NewGuid().ToString()
                };

                sitesService.Save(id, sitemodel.Email, site);

                var shortUrl = GenerateSiteShortLink(site.verification_code);

                return RedirectToAction("CreateSuccess", new RouteValueDictionary
                {
                    {
                        "msg",
                        "El sitio se ha creado satisfactoriamente, accedé ya al mismo:"
                    }
                    ,
                    {
                        "url",
                        shortUrl
                    }
                    ,
                    {
                        "title",
                        site.title
                    }
                });
            }

            return View();
        }
Ejemplo n.º 7
0
        public Sites Save(int userid, string email, Sites site)
        {
            site.date_created = DateTime.Now;

            db.Sites.AddObject(site);
            db.SitesOwners.AddObject(new SitesOwners()
            {
                Sites = site,
                user_id = userid,
                email = email
            });

            db.SaveChanges();

            return site;
        }