public void addFollow(string openId, string postsId) { SqlSugarClient db = SqlSugarInstance.newInstance(); tbl_posts posts = db.Queryable <tbl_posts>().Where(o => o.postsID == postsId).First(); string postsMaker = posts.postsMaker; tbl_userFollowed followed = new tbl_userFollowed(); followed.followId = Guid.NewGuid().ToString(); followed.userId = openId; followed.followedUser = postsMaker; followed.followedTime = DateTime.Now; tbl_userFollowed tf = new tbl_userFollowed(); long i = db.Queryable <tbl_userFollowed>().Where(o => o.userId == openId && o.followedUser == postsMaker).Count(); if (i == 0) { db.Insertable <tbl_userFollowed>(followed).ExecuteCommand(); } }
public bool savePosts(string postsMaker, string postsContent, int picsCount, string postsId, double latitude, double longitude, string location, string postsType, int ifOfficial, int ifLY) { PostsModel model = new PostsModel(); model.postsMaker = postsMaker; model.postsContent = postsContent; model.postsID = postsId; model.postsMakeDate = DateTime.Now; model.postsPicCount = picsCount; model.latitude = latitude; model.longitude = longitude; model.postsLocation = location; model.postsType = postsType; model.ifOfficial = ifOfficial; model.ifLY = ifLY; tbl_posts posts = PostsConverter.postsModelToEntity(model); PostsProvider provider = new PostsProvider(); provider.savePosts(posts); return(true); }
public static tbl_posts postsModelToEntity(PostsModel model) { tbl_posts entity = new tbl_posts(); entity.postsCollected = 0; entity.postsContent = model.postsContent; entity.postsID = model.postsID; entity.postsLoved = 0; entity.postsMakeDate = DateTime.Now; entity.postsMaker = model.postsMaker; entity.postsPicCount = model.postsPicCount; entity.postsReaded = 0; entity.postsStatus = 0; //0 means OK, 1 means unauthorized entity.postsReported = 0; entity.latitude = model.latitude; entity.longitude = model.longitude; entity.postsLocation = model.postsLocation; entity.postsType = model.postsType; entity.ifOfficial = model.ifOfficial; entity.ifLY = model.ifLY; return(entity); }