public void addReply(Reply reply) { if(reply.Id != 0) { var original = _repo.Find<Reply>(reply.Id); original.IsHidden = true; _repo.SaveChanges(); } else { _repo.Add<Reply>(reply); _repo.SaveChanges(); } }
public IHttpActionResult Post(Reply reply) { if (ModelState.IsValid) { if (reply.Id == 0) { var userId = this.User.Identity.GetUserId(); reply.UserId = userId; reply.DateCreated = DateTime.Now; reply.IsHidden = false; _repo.addReply(reply); return Ok(); } else { _repo.addReply(reply); return Ok(); } } return BadRequest(); }