Example #1
0
    public IActionResult Upsert([FromForm] Post p, int id)
    {
        var post = posts.Read(id);

        if (post != null)
        {
            posts.Delete(id);
        }
        p.PostId = id;
        posts.Add(p);
        return(RedirectToAction("ReadFive"));
    }
    public IActionResult Update([FromBody] Post p, int id)
    {
        var post = posts.Read(id);

        if (post != null)
        {
            posts.Delete(id);
        }
        p.PostId = id;
        posts.Add(p);
        return(Ok(posts));
    }