public void AddPost_tag(Post_tag pt) { using (var db = new Sova()) { pt.postid = db.Post_tag.Max(p => pt.id) + 1; db.Add(pt); db.SaveChanges(); } }
//Post_tag public static Post_tagModel ptMap(Post_tag pt, IUrlHelper url) { return(new Post_tagModel { Url = url.Link(Config.Post_tagRoute, new { id = pt.id }), id = pt.id, postid = pt.postid, tagkeyword = pt.tagkeyword }); }
public bool UpdatePost_tag(Post_tag post_tag) { using (var db = new Sova()) try { db.Attach(post_tag); db.Entry(post_tag).State = EntityState.Modified; return(db.SaveChanges() > 0); } catch (DbUpdateConcurrencyException) { return(false); } }