Ejemplo n.º 1
0
 public void Post([FromBody] PostDto post)
 {
     var state = new PostState
     {
         Id = post.StateId,
         IsDone = post.IsDone,
         IsTodo = post.IsTodo,
         IsHidden = post.IsHidden,
         UserId = UserSession.UserId,
         PostId = post.Id
     };
     _service.UpdateState(state);
 }
Ejemplo n.º 2
0
 private PostDto AdaptModelToDto(PostState model)
 {
     return new PostDto
     {
         Id = model.Post.Id,
         Name = model.Post.Name,
         Content = model.Post.Content,
         Timestamp = model.Post.Timestamp,
         IsSticky = model.Post.IsSticky,
         StateId = model.Id,
         IsTodo = model.IsTodo,
         IsDone = model.IsDone,
         IsHidden = model.IsHidden,
     };
 }
Ejemplo n.º 3
0
        public void UpdateState(PostState postState)
        {
            using (var ctx = new SkillSharingContext())
            {
                var state = ctx.PostStates.SingleOrDefault(x => x.Id == postState.Id && x.UserId == postState.UserId);
                if (state == null)
                {
                    state = new PostState
                    {
                        Id = Guid.NewGuid(),
                        PostId = postState.PostId,
                        UserId = postState.UserId
                    };
                    ctx.PostStates.Add(state);
                }

                state.IsTodo = postState.IsTodo;
                state.IsDone = postState.IsDone;
                state.IsHidden = postState.IsHidden;

                ctx.SaveChanges();
            }
        }