Inheritance: BlogEngine.Core.Web.Controls.BlogBasePage
Exemple #1
0
        public string GetPosts()
        {
            List<post> posts = new List<post>();
            post newPost = new post();
            newPost.id = 1;
            newPost.title = "Rails is Omakase";
            newPost.author = "d2h";
            newPost.publishedAt = new DateTime(2012, 12, 27);
            newPost.intro = "There are lots of a la carte software environments in the world Places where in order...";
            newPost.extended = "I want this for my ORM, I want that for my template language, and lets finish it ....";
            posts.Add(newPost);

            newPost = new post();
            newPost.id = 2;
            newPost.title = "The Parley Letter";
            newPost.author = "d2h";
            newPost.publishedAt = new DateTime(2012, 12, 24);
            newPost.intro = "My appearance on the bury rogues podcast was amazing";
            newPost.extended = "A Long list of topics were raised and i took a time to ramble at large about all of them ...";
            posts.Add(newPost);

            //string json = string.Empty;
            //using (MemoryStream ms = new MemoryStream())
            //{
            //    DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(post));
            //    ser.WriteObject(ms, newPost);
            //    json = System.Text.Encoding.UTF8.GetString(ms.GetBuffer(), 0, Convert.ToInt16(ms.Length));
            //}

            return posts.ToString();
        }
 public void EdytujPost(post new_post)
 {
     using (LinqBlogDataContext dp = new LinqBlogDataContext())
         {
             var e = dp.posts.Single(x => x.ID == new_post.ID);
             e.tytul = new_post.tytul;
             e.tresc = new_post.tresc;
             e.status = new_post.status;
             e.data_modyfikacji = DateTime.Now;
             dp.SubmitChanges();
         }
 }
Exemple #3
0
 public ActionResult edytujPost(post k)
 {
     try
     {
         //ViewData["id"] = id;
         db_admin.EdytujPost(k);
         return RedirectToAction("Index", "Home");
     }
     catch
     {
         return RedirectToAction("Error", "Shared");
     }
 }
Exemple #4
0
        // GET: posts/Delete/5
        public async Task <ActionResult> Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            post post = await db.post.FindAsync(id);

            if (post == null)
            {
                return(HttpNotFound());
            }
            return(View(post));
        }
        public IHttpActionResult Deletepost(int id)
        {
            post post = db.Posts.Find(id);

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

            db.Posts.Remove(post);
            db.SaveChanges();

            return(Ok(post));
        }
Exemple #6
0
        // GET: posts/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            post post = db.post.Find(id);

            if (post == null)
            {
                return(HttpNotFound());
            }
            return(View(post));
        }
        public override BaseEntity Update(object Obj)
        {
            dbEntities = new mpi_dbEntities();
            post post   = (post)Obj;
            post DBpost = (post)GetById(post.id);

            if (DBpost == null)
            {
                return(null);
            }
            dbEntities.Entry(DBpost).CurrentValues.SetValues(post);
            dbEntities.SaveChanges();
            return(post);
        }
    void getNewURL()
    {
        url  = "https://maps.googleapis.com/maps/api/staticmap?";
        url += "&zoom=18&size=200x432&maptype=satellite";
        string key      = "&key=AIzaSyDzZE_iL05RSddPakPeDCcDR56HdWw34Is";
        string location = "&center=" + global.latitude + "," + global.longitude;

        url += key;
        url += location;

        global.displayedPosts = new List <post>();

        FirebaseDatabase.DefaultInstance.GetReference("posts").GetValueAsync().ContinueWith(task =>
        {
            DataSnapshot snapshot = task.Result;
            int i = 1;
            while (true)
            {
                if (snapshot.Child(i.ToString()).Child("dt").Value == null)
                {
                    break;
                }
                float markerLat = float.Parse(snapshot.Child(i.ToString()).Child("latitude").Value.ToString());
                float markerLon = float.Parse(snapshot.Child(i.ToString()).Child("longitude").Value.ToString());

                float dist = calculateDistance(global.latitude, global.longitude, markerLat, markerLon);
                Debug.Log(dist);

                post p      = new post();
                p.dt        = snapshot.Child(i.ToString()).Child("dt").Value.ToString();
                p.pst       = snapshot.Child(i.ToString()).Child("pst").Value.ToString();
                p.user      = snapshot.Child(i.ToString()).Child("user").Value.ToString();
                p.likes     = int.Parse(snapshot.Child(i.ToString()).Child("likes").Value.ToString());
                p.longitude = markerLon;
                p.latitude  = markerLat;

                if (dist <= 200)
                {
                    url += markerText(p);
                }
                if (dist <= 50)
                {
                    global.displayedPosts.Add(p);
                }

                i++;
            }
            Debug.Log(url);
        });
    }
Exemple #9
0
        public async Task CreateDbAsync()
        {
            db = Database.Create <MySqlConnection>(ConnectionStrings.Get(_connectionStringName));
            await db.ExecuteAsync(@"

DROP TABLE IF EXISTS posts;
DROP TABLE IF EXISTS authors;

CREATE TABLE posts (
	id				bigint AUTO_INCREMENT NOT NULL,
	title			varchar(127) NOT NULL,
	author			bigint NOT NULL,
	PRIMARY KEY (id)
) ENGINE=INNODB;

CREATE TABLE authors (
	id				bigint AUTO_INCREMENT NOT NULL,
	name			varchar(127) NOT NULL,
	PRIMARY KEY (id)
) ENGINE=INNODB;

			"            );


            var a1 = new author();

            a1.name = "Bill";
            await db.InsertAsync(a1);

            var a2 = new author();

            a2.name = "Ted";
            await db.InsertAsync(a2);

            var p = new post();

            p.title  = "post1";
            p.author = a1.id;
            await db.InsertAsync(p);

            p        = new post();
            p.title  = "post2";
            p.author = a1.id;
            await db.InsertAsync(p);

            p        = new post();
            p.title  = "post3";
            p.author = a2.id;
            await db.InsertAsync(p);
        }
Exemple #10
0
        public void CreateDB()
        {
            db = new Database(_connectionStringName);
            db.Execute(@"

DROP TABLE IF EXISTS posts;
DROP TABLE IF EXISTS authors;

CREATE TABLE posts (
	id				bigint AUTO_INCREMENT NOT NULL,
	title			varchar(127) NOT NULL,
	author			bigint NOT NULL,
	PRIMARY KEY (id)
) ENGINE=INNODB;

CREATE TABLE authors (
	id				bigint AUTO_INCREMENT NOT NULL,
	name			varchar(127) NOT NULL,
	PRIMARY KEY (id)
) ENGINE=INNODB;

			"            );


            var a1 = new author();

            a1.name = "Bill";
            db.Insert(a1);

            var a2 = new author();

            a2.name = "Ted";
            db.Insert(a2);

            var p = new post();

            p.title  = "post1";
            p.author = a1.id;
            db.Insert(p);

            p        = new post();
            p.title  = "post2";
            p.author = a1.id;
            db.Insert(p);

            p        = new post();
            p.title  = "post3";
            p.author = a2.id;
            db.Insert(p);
        }
Exemple #11
0
        public post getPostbyID(int _id)
        {
            post fundPost = new post();

            try
            {
                fundPost = db.posts.Find(_id);
                return(fundPost);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #12
0
 void displayPost(post p)
 {
     postDetails.SetActive(true);
     postText.text = p.pst;
     foreach (Button button in buttons)
     {
         Debug.Log(button);
         button.gameObject.SetActive(false);
     }
     foreach (Button button in buttons)
     {
         Debug.Log(button.gameObject.activeSelf);
     }
 }
Exemple #13
0
        public async Task <ActionResult <SucceedInfomation> > createpostcontent([FromForm] PostPayload postpayload)
        {
            SucceedInfomation succeedinformation = new SucceedInfomation();
            post Newpost = new post()
            {
                posttitle = postpayload.posttitle
            };

            if (postpayload.imgfile == null || postpayload.posttitle.Length < 3)
            {
                succeedinformation.Issucceed     = false;
                succeedinformation.SucceedDetail = "Please complete the form";
                return(Ok(succeedinformation));
            }
            if (postpayload.imgfile.FileName.EndsWith(".jpg"))
            {
                Newpost.titleimgurl = await _imgservice.SaveFileJpg(postpayload.imgfile);
            }
            else if (postpayload.imgfile.FileName.EndsWith(".png"))
            {
                Newpost.titleimgurl = await _imgservice.SaveFilePng(postpayload.imgfile);
            }
            // else if(postpayload.imgfile.Length  == 0)
            // {
            //  succeedinformation.Issucceed = false;
            //  succeedinformation.SucceedDetail = "file format invalide , pls use jpg or png";
            //  return Ok(succeedinformation);
            // }
            content Newcontent = new content()
            {
                contentdetail = postpayload.contentdetail
            };

            _Context.posts.Add(Newpost);
            _Context.contents.Add(Newcontent);
            _Context.SaveChanges();
            var Newposcontent = new postcontent()
            {
                postid             = Newpost.postid,
                contentid          = Newcontent.contentid,
                userid             = postpayload.userid,
                categoryid         = postpayload.categoryid,
                postcontentcreated = DateTime.UtcNow
            };

            _Context.postcontents.Add(Newposcontent);
            _Context.SaveChanges();
            return(succeedinformation);
        }
        public string post(string user_id, string select, string title, string content)
        {
            post      post1 = new post();
            Hashtable ht    = post1.Post(user_id, select, title, content);

            foreach (string i in common.pic)
            {
                insert_post_picture(i, post1.post_id);
            }
            ht.Add("picture", common.pic);
            JavaScriptSerializer js = new JavaScriptSerializer();
            string strJson          = js.Serialize(ht);

            return(strJson);
        }
Exemple #15
0
 public void NewPost(post newPost)
 {
     try
     {
         using (BlogEntities db = new BlogEntities())
         {
             db.posts.Add(newPost);
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #16
0
        protected void imgExcluiComentario_Command(object sender, CommandEventArgs e)
        {
            comentario Comentario = CR.GetOne(int.Parse(e.CommandArgument.ToString()));
            post       Postagem   = PR.GetOne(Comentario.id_post);

            if (Comentario.id_usuarioremetente == UsuarioAtual.id_usuario || Postagem.id_usuario == UsuarioAtual.id_usuario)
            {
                CR.Delete(Comentario.id_comentario);
                //CriaTimeline();

                /*rptComentario.DataBind();
                 * rptPostagem.DataBind();*/
                CriaComentario(Postagem.id_post);
            }
        }
Exemple #17
0
        public IHttpActionResult Deletepost(Guid guid)
        {
            post post = db.post.Where(u => u.guid == guid).FirstOrDefault <post>();

            //post post = db.post.Find(id);
            if (post == null)
            {
                return(NotFound());
            }

            db.post.Remove(post);
            db.SaveChanges();

            return(Ok(post));
        }
        // GET: Admin/Post/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            post mpost = db.Posts.Find(id);

            if (mpost == null)
            {
                return(HttpNotFound());
            }
            ViewBag.listTopic = db.Topics.Where(m => m.status != 0).ToList();
            return(View(mpost));
        }
Exemple #19
0
        // GET: posts/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            post post = db.posts.Find(id);

            if (post == null)
            {
                return(HttpNotFound());
            }
            ViewBag.author_userId = new SelectList(db.users, "userId", "firstName", post.author_userId);
            return(View(post));
        }
Exemple #20
0
        protected void imgExcluiComentario_Command(object sender, CommandEventArgs e)
        {
            comentario Comentario = CR.GetOne(int.Parse(e.CommandArgument.ToString()));
            post       Postagem   = PR.GetOne(Comentario.id_post);

            if (Comentario.id_usuarioremetente == UsuarioAtual.id_usuario || Postagem.id_usuario == UsuarioAtual.id_usuario)
            {
                CR.Delete(Comentario.id_comentario);
                CriaTimeline();
                if (Session["idpostaberto"] != null)
                {
                    CriaComentario(Postagem.id_post);
                }
            }
        }
Exemple #21
0
        //public Dictionary<string, string> post()
        //{
        //    try
        //    {
        //        Docupload d = new Docupload();
        //        var file = Request.Form.Files[0];
        //        var folderName = Path.Combine("Resources", "Images");
        //        var pathToSave = Path.Combine(Directory.GetCurrentDirectory(), folderName);

        //        if (file.Length > 0)
        //        {
        //            var fileName = ContentDispositionHeaderValue.Parse(file.ContentDisposition).FileName.Trim('"');
        //            var fullPath = Path.Combine(pathToSave, fileName);
        //            var dbPath = Path.Combine(folderName, fileName);
        //            using (var stream = new FileStream(fullPath, FileMode.Create))
        //            {
        //                file.CopyTo(stream);
        //            }
        //            d.DocName = fileName;
        //            d.Path = dbPath;
        //            //d.AccepterId = Convert.ToInt32(Message);
        //            context.Add(d);
        //            context.SaveChanges();

        //            return Ok();
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        return StatusCode(500, $"Internal server error: {ex}");
        //    }
        //}


        public IHttpActionResult Put(int id, [FromBody] post s)
        {
            post a = context.posts.Single(post => post.post_id == id);

            a.title           = s.title;
            a.category        = s.category;
            a.description     = s.description;
            a.target_amount   = s.target_amount;
            a.received_amount = s.received_amount;


            //context.Update(s);
            context.SaveChanges();
            return(Ok());
        }
Exemple #22
0
		public async Task CreateDbAsync()
		{
			db = new Database(_connectionStringName);
			await db.ExecuteAsync(@"

DROP TABLE IF EXISTS posts;
DROP TABLE IF EXISTS authors;

CREATE TABLE posts (
	id				bigint AUTO_INCREMENT NOT NULL,
	title			varchar(127) NOT NULL,
	author			bigint NOT NULL,
	PRIMARY KEY (id)
) ENGINE=INNODB;

CREATE TABLE authors (
	id				bigint AUTO_INCREMENT NOT NULL,
	name			varchar(127) NOT NULL,
	PRIMARY KEY (id)
) ENGINE=INNODB;

			");


			var a1 = new author();
			a1.name = "Bill";
			await db.InsertAsync(a1);

			var a2 = new author();
			a2.name = "Ted";
			await db.InsertAsync(a2);

			var p = new post();
			p.title = "post1";
			p.author = a1.id;
			await db.InsertAsync(p);

			p = new post();
			p.title = "post2";
			p.author = a1.id;
			await db.InsertAsync(p);

			p = new post();
			p.title = "post3";
			p.author = a2.id;
			await db.InsertAsync(p);

		}
 public override bool Delete(object Obj)
 {
     try
     {
         post post = (post)Obj;
         dbEntities = new mpi_dbEntities();
         dbEntities.posts.Remove(post);
         dbEntities.SaveChanges();
         return(true);
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         return(false);
     }
 }
Exemple #24
0
 public void DelPost(int _id)
 {
     try
     {
         var post = new post {
             C_id = _id
         };
         db.posts.Attach(post);
         db.posts.Remove(post);
         db.SaveChanges();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #25
0
        public ActionResult AddPost(post post)
        {
            if (ModelState.IsValid)
            {
                int id     = Convert.ToInt32(Session["id"]);
                var writer = db.users.Where(model => model.id == id).FirstOrDefault();
                post.state   = 0;
                post.user_id = writer.id;
                db.posts.Add(post);
                db.SaveChanges();


                return(RedirectToAction("newHomePage", "Home"));
            }
            return(View(post));
        }
Exemple #26
0
 /// <summary>
 /// Sets the post defaults.
 /// </summary>
 /// <param name="_p">Instatiated Post</param>
 private static void setPostDefaults(ref post _p)
 {
     _p.post_author    = post_author;
     _p.post_status    = post_status;
     _p.post_type      = post_type;
     _p.comment_status = sub_status;
     _p.ping_status    = sub_status;
     // Added by Jun 12/2020
     // The post_content in Wordpress post table need to have an value instead of null
     // T12262020 - A - create - workshop
     _p.post_content          = post_content;
     _p.post_excerpt          = post_excerpt;
     _p.to_ping               = to_ping;
     _p.pinged                = pinged;
     _p.post_content_filtered = post_content_filtered;
 }
Exemple #27
0
    protected void GridView1_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
    {
        int idsel = Convert.ToInt32(GridView1.DataKeys[e.NewSelectedIndex].Value);

        Panel1.Visible  = true;
        Btnupd.Visible  = true;
        Btnsave.Visible = false;
        post postEdit = new post();

        postEdit       = blogNegocio.GetPostbyID(idsel);
        txttitulo.Text = postEdit.titulo;
        txtpost.Text   = postEdit.post1;
        txtimg.Text    = postEdit.urlimagen;
        txtautor.Text  = postEdit.autor;
        lblID.Text     = idsel.ToString();
    }
        public IActionResult Edit(int id, post post, IFormFile image, string returnUrl = null)
        {
            if (id != post.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                this.repository.UpdateEntity(post, image);

                return(RedirectToLocal(returnUrl));
            }

            ViewData["ReturnUrl"] = returnUrl;
            return(View(post));
        }
Exemple #29
0
        public ViewResult makepost(Homelist homelistviewmodel)
        {
            var      id      = _post.getallposts().Max(c => c.p_id) + 1;
            Homelist list    = new Homelist();
            var      newpost = new post()
            {
                p_id      = id,
                p_content = homelistviewmodel.newpost.p_content,
                P_user    = homelistviewmodel.newpost.P_user,
                comments  = new List <Icomment>(),
                like      = 0
            };

            list.newpost  = _post.addpost(newpost);
            list.allposts = _post.getallposts();
            return(View("makepost", list));
        }
Exemple #30
0
 public ActionResult Edit([Bind(Include = "postid,title,text,users_userid,date")] post post)
 {
     if (ModelState.IsValid)
     {
         //Fin the user id
         string     username = User.Identity.Name.ToString();
         var        userid   = db.AspNetUsers.SqlQuery("SELECT * FROM AspNetUsers WHERE UserName = "******"'" + username + "'").ToList();
         AspNetUser user     = userid[0];
         post.date            = DateTime.Now;
         post.users_userid    = user.Id;
         db.Entry(post).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.users_userid = new SelectList(db.AspNetUsers, "Id", "Email", post.users_userid);
     return(View(post));
 }
        public ActionResult Edit(post p)
        {
            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri("http://localhost:520122/api/");
                var putTask = client.PutAsJsonAsync <post>("posts/" + p.postNumber, p);
                putTask.Wait();

                var result = putTask.Result;
                if (result.IsSuccessStatusCode)
                {
                    return(RedirectToAction("Index"));
                }
            }
            ModelState.AddModelError(string.Empty, "Error");
            return(View(p));
        }
Exemple #32
0
        protected void Button2_Click(object sender, EventArgs e)
        {
            HttpCookie cookie   = Request.Cookies["rowenref"];//declaration of cookie
            user       usrtrash = db.users.First(use => use.username == cookie["username"]);


            post Pstid = db.posts.First(use => use.user_id == Convert.ToInt16(cookie["userid"]));


            tbl_gallery gll = db.tbl_galleries.First(use => use.pst_id == Pstid.pst_id);

            string file_name = Pstid.Image;
            string Username  = usrtrash.Image;
            string userpaths = Server.MapPath("../profilepic/oreginal/" + Username);
            string paths     = Server.MapPath("../images/oreginal/" + file_name);

            FileInfo userfiles = new FileInfo(userpaths);
            FileInfo files     = new FileInfo(paths);

            if (files.Exists)
            {
                files.Delete();
            }
            else if (userfiles.Exists)
            {
                userfiles.Delete();
            }
            else
            {
            }

            db.sp_DELETE_tbl_commentuser(Convert.ToInt16(cookie["userid"])); //delete user comment
            db.sp_DELETE_tbl_postuser(Convert.ToInt16(cookie["userid"]));    //delete user post

            db.tbl_galleries.DeleteOnSubmit(gll);
            db.users.DeleteOnSubmit(usrtrash);
            db.SubmitChanges();

            // cookie distroy


            cookie.Expires = DateTime.Now.AddDays(-1);
            Response.Cookies.Add(cookie);
            Response.Redirect("home.aspx");
        }
Exemple #33
0
        /*protected void bttPostaComentario_Command(object sender, CommandEventArgs e)
         * {
         *  if (txtComentario.Text != "")
         *  {
         *      comentario Comentario = new comentario();
         *      Comentario.id_post = (int)Session["idpostaberto"];
         *      Comentario.id_usuarioremetente = UsuarioAtual.id_usuario;
         *      Comentario.comentariocontent = txtComentario.Text;
         *      Comentario.datacomentario = DateTime.Now;
         *      CR.Salvar(Comentario);
         *
         *      txtComentario.Text = "";
         *  }
         *  CriaComentario((int)Session["idpostaberto"]);
         * }*/

        protected void bttComentar_Command(object sender, CommandEventArgs e)
        {
            if (int.Parse(e.CommandArgument.ToString()) != 0)
            {
                pnlComentario.Attributes.Add("style", "Display: flex");
                Session["idpostaberto"] = int.Parse(e.CommandArgument.ToString());
                post          Postagem = PR.GetOne((int)Session["idpostaberto"]);
                followusuario Seguindo = FUR.GetOne(UsuarioAtual.id_usuario, Postagem.id_usuario);
                usuario       Usuario  = UR.GetOne(Postagem.id_usuario);
                txtComentario.Text         = "";
                txtComentario.Enabled      = true;
                bttPostaComentario.Enabled = true;

                if (Seguindo == null && Postagem.id_usuario != UsuarioAtual.id_usuario)
                {
                    txtComentario.Text         = "Você não segue " + Usuario.nicknameusuario + " para comentar em seu post!";
                    txtComentario.Enabled      = false;
                    bttPostaComentario.Enabled = false;
                }

                DataTable table = new DataTable();
                table.Columns.Add("DataPostagem");
                table.Columns.Add("NomeUsuario");
                table.Columns.Add("NicknameUsuario");
                table.Columns.Add("LinkfotoUsuario");
                table.Columns.Add("ConteudoPost");
                table.Columns.Add("id_usuario");
                table.Columns.Add("id_post");

                DataRow datarow = table.NewRow();
                datarow["id_usuario"]      = Postagem.id_usuario;
                datarow["DataPostagem"]    = Postagem.datapostagem;
                datarow["ConteudoPost"]    = Postagem.contentpost;
                datarow["NomeUsuario"]     = Usuario.nomeusuario;
                datarow["NicknameUsuario"] = Usuario.nicknameusuario;
                datarow["LinkfotoUsuario"] = Usuario.linkfoto;
                datarow["id_post"]         = Postagem.id_post;
                table.Rows.Add(datarow);

                rptPostComentario.DataSource = table;
                rptPostComentario.DataBind();

                CriaComentario(int.Parse(e.CommandArgument.ToString()));
            }
        }
Exemple #34
0
            public post MapIt(post p, author a)
            {
                // Get existing author object, or if not found store this one
                author aExisting;

                if (authors.TryGetValue(a.id, out aExisting))
                {
                    a = aExisting;
                }
                else
                {
                    authors.Add(a.id, a);
                }

                // Wire up objects
                p.author_obj = a;
                return(p);
            }
Exemple #35
0
        public void DodajPost(Klasa new_post)
        {
            using (LinqBlogDataContext dp = new LinqBlogDataContext())
                {
                    var p = new post();
                    p.tytul = new_post.tytul;
                    p.tresc = new_post.tresc;
                    p.status = new_post.status;
                    p.data_dodania = DateTime.Now;
                    dp.posts.InsertOnSubmit(p);
                    dp.SubmitChanges();

                    var t = new tagi();
                    t.id_posta = p.ID;
                    t.keywords = new_post.keywords;
                    t.description = new_post.description;
                    dp.tagis.InsertOnSubmit(t);
                    dp.SubmitChanges();

                }
        }
Exemple #36
0
            public post MapIt(post p, author a)
            {
                // Get existing author object, or if not found store this one
                author aExisting;
                if (authors.TryGetValue(a.id, out aExisting))
                    a = aExisting;
                else
                    authors.Add(a.id, a);

                // Wire up objects
                p.author_obj = a;
                return p;
            }
Exemple #37
0
            public author MapIt(author a, post p)
            {
                // Terminating call.  Since we can return null from this function
                // we need to be ready for PetaPoco to callback later with null
                // parameters
                if (a == null)
                    return current;

                // Is this the same author as the current one we're processing
                if (current != null && current.id == a.id)
                {
                    // Yes, just add this post to the current author's collection of posts
                    current.posts.Add(p);

                    // Return null to indicate we're not done with this author yet
                    return null;
                }

                // This is a different author to the current one, or this is the
                // first time through and we don't have an author yet

                // Save the current author
                var prev = current;

                // Setup the new current author
                current = a;
                current.posts = new List<post>();
                current.posts.Add(p);

                // Return the now populated previous author (or null if first time through)
                return prev;
            }