public bool UpdateLike(LikeEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .Likes .Single(e => e.LikeID == model.LikeID && e.UserID == _userID); entity.LikedPost = model.LikedPost; //entity.ModifiedUtc = DateTimeOffset.UtcNow; return(ctx.SaveChanges() == 1); } }
public IHttpActionResult Put(LikeEdit like) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreateLikeService(); if (!service.UpdateLike(like)) { return(InternalServerError()); } return(Ok()); }
public bool UpdateLike(LikeEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .Likes .Single(e => e.LikeID == model.LikeID && e.UserID == _userID); entity.LikeID = model.LikeID; entity.IsLiked = model.IsLiked; return(ctx.SaveChanges() == 1); } }
public bool UpdateLike(LikeEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .Likes .Single(e => e.LikeId == model.LikeId); //entity.PostId = model.PostId; entity.UserId = model.UserId; return(ctx.SaveChanges() == 1); } }
public bool UpdateLike(LikeEdit model) { using (var ctx = new ApplicationDbContext()) { var likeEntity = ctx.Likes.Single(p => p.Id == model.Id && p.ApplicationUserId == _userId.ToString()); if (likeEntity == null) { return(false); } likeEntity.PostId = model.PostId; likeEntity.ModifiedUtc = DateTimeOffset.UtcNow; return(ctx.SaveChanges() == 1); } }