Ejemplo n.º 1
0
        //Create
        public bool CreateLike(LikeCreate model)
        {
            using (var like = new ApplicationDbContext())
            {
                while (model.LikedPost.Equals(true))
                {
                    Console.WriteLine($"{model.liker} likes this.");
                }

                return(like.SaveChanges() == 1);
            }
        }
Ejemplo n.º 2
0
        public bool CreateLike(LikeCreate model)
        {
            var entity = new Like()
            {
                Liker = model.Liker
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Likes.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
Ejemplo n.º 3
0
        // LIKE METHODS
        // Create a Like on a post using a foreign key relationship

        public bool CreateLike(LikeCreate model)
        {
            var entity = new Like()
            {
                OwnerId    = _ownerId,
                CreatedUtc = DateTimeOffset.Now
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Notes.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
Ejemplo n.º 4
0
        public IHttpActionResult Post(LikeCreate like)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var service = CreateLikeService();

            if (!service.CreateLike(like))
            {
                return(InternalServerError());
            }
            return(Ok());
        }
Ejemplo n.º 5
0
        public bool CreateLike(LikeCreate model)
        {
            var likeEntity = new Like
            {
                PostId            = model.PostId,
                ApplicationUserId = _userId.ToString(),
                CreatedUtc        = DateTimeOffset.Now
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Likes.Add(likeEntity);
                return(ctx.SaveChanges() == 1);
            }
        }
Ejemplo n.º 6
0
        public bool CreateLike(LikeCreate model)
        {
            var entity =
                new Like()
            {
                AuthorId = _userId,
                PostId   = model.PostId,
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Likes.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
Ejemplo n.º 7
0
        public bool CreateLike(LikeCreate model)
        {
            var entity = new Like()
            {
                Author    = _userId,
                LikedPost = model.LikedPost,
                Liked     = model.Liked
            };

            using (var context = new ApplicationDbContext())
            {
                context.Likes.Add(entity);
                return(context.SaveChanges() == 1);
            }
        }
Ejemplo n.º 8
0
        public IHttpActionResult Post(LikeCreate note)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var service = CreateNoteService();

            if (!service.CreateLike(note))
            {
                return(InternalServerError());
            }

            return(Ok("The Like was successfullu created"));
        }
Ejemplo n.º 9
0
        public bool CreateLike(LikeCreate model)
        {
            var entity =
                new Like()
            {
                PostTitle = model.PostTitle,
                PostText  = model.PostText,
                IsLiked   = model.IsLiked,
                UserID    = model.UserID,
                UserName  = model.UserName
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Likes.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
Ejemplo n.º 10
0
        public bool CreateLike(LikeCreate model)
        {
            var postContext = new ApplicationDbContext();

            Post post = postContext.Posts.Find(model.PostId);

            var entity = new Like()
            {
                Liker  = _userId,
                PostId = model.PostId
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Likes.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }