Exemplo n.º 1
0
 public ActionResult Post()
 {
     string userName = User.Identity.Name;
     AccountModel user = AccountRepository.GetAccount(userName);
     PostModel postModel = new PostModel();
     postModel.UserId = user.UserId;
     return View(postModel);
 }
Exemplo n.º 2
0
 public PostModel GetPost(int postId)
 {
     using (Entities entity = new Entities(BaseBISL.ConnectionString))
     {
         var post = entity.WeightMsg_Post.Include("WeightUser").Where(e => e.Post_ID == postId).FirstOrDefault();
         PostModel postModel = new PostModel();
         postModel.PostId = post.Post_ID;
         postModel.DateCreated = post.DateCreated;
         postModel.DateModified = post.DateModified;
         postModel.DisplayName = post.WeightUser.DisplayName;
         postModel.PostContent = post.Post_Content;
         postModel.Title = post.Title;
         postModel.UserId = post.UserID;
         postModel.UserName = post.WeightUser.UserName;
         postModel.Comments = this.GetComments(postModel.PostId);
         return postModel;
     }
 }
Exemplo n.º 3
0
        public List<PostModel> GetPosts()
        {
            List<PostModel> postList = new List<PostModel>();
            using (Entities entity = new Entities(BaseBISL.ConnectionString))
            {
                var posts = entity.WeightMsg_Post.Include("WeightUser").Select(e => e).OrderByDescending(f => f.DateCreated);

                foreach (WeightMsg_Post post in posts)
                {
                    PostModel postModel = new PostModel();
                    postModel.PostId = post.Post_ID;
                    postModel.DateCreated = post.DateCreated;
                    postModel.DateModified = post.DateModified;
                    postModel.DisplayName = post.WeightUser.DisplayName;
                    postModel.PostContent = post.Post_Content;
                    postModel.Title = post.Title;
                    postModel.UserId = post.UserID;
                    postModel.UserName = post.WeightUser.UserName;
                    postModel.Comments = this.GetComments(postModel.PostId);
                    postList.Add(postModel);
                }
            }
            return postList;
        }
Exemplo n.º 4
0
 public bool InsertPost(PostModel postModel)
 {
     using (Entities entity = new Entities(BaseBISL.ConnectionString))
     {
         WeightMsg_Post post = new WeightMsg_Post();
         post.DateCreated = DateTime.Now;
         post.DateModified = DateTime.Now;
         post.Post_Content = postModel.PostContent;
         post.Title = postModel.Title;
         post.UserID = postModel.UserId;
         entity.AddToWeightMsg_Post(post);
         int rows = entity.SaveChanges();
         if (rows > 0)
             return true;
         else
             return false;
     }
 }
Exemplo n.º 5
0
 public ActionResult Post(PostModel postModel)
 {
     PostRepository.InsertPost(postModel);
     return RedirectToAction("Index");
 }