public ActionResult <IEnumerable <Blog> > Edit([FromBody] Blog editedBlog, int id)
 {
     try
     {
         return(Ok(_bs.Edit(editedBlog, id)));
     }
     catch (System.Exception error)
     {
         return(BadRequest(error.Message));
     }
 }
Beispiel #2
0
 public ActionResult <Blog> Edit(int id, [FromBody] Blog updatedBlog)
 {
     try
     {
         return(Ok(_bs.Edit(id, updatedBlog)));
     }
     catch (System.Exception err)
     {
         return(BadRequest(err.Message));
     }
 }
Beispiel #3
0
 [HttpPut("{blogsId}")] //EDIT
 public ActionResult <Blog> editBlogs(string blogId, Blog editBlogs)
 {
     try
     {
         editBlogs.blogId = blogId;
         return(Ok(_service.Edit(editBlogs)));
     }
     catch (System.Exception err)
     {
         return(BadRequest(err.Message));
     }
 }
        public async Task <ActionResult <Blog> > Edit(int id, [FromBody] Blog editData)
        {
            try
            {
                Profile userInfo = await HttpContext.GetUserInfoAsync <Profile>();

                //helpful to check in service if creator is whoever is logged in
                editData.Id = id;
                return(Ok(_bs.Edit(editData, userInfo.Id)));
            }
            catch (System.Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
 public ActionResult <Blog> Edit(int id, [FromBody] Blog updatedBlog)
 {
     try
     {
         string userId = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value;
         // NOTE DONT TRUST THE USER TO TELL YOU WHO THEY ARE!!!!
         updatedBlog.AuthorId = userId;
         updatedBlog.Id       = id;
         return(Ok(_bs.Edit(updatedBlog)));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
Beispiel #6
0
        public async Task <ActionResult <Blog> > EditAsync([FromBody] Blog editData, int id)
        {
            try
            {
                Profile userInfo = await HttpContext.GetUserInfoAsync <Profile>();

                editData.Id        = id;
                editData.CreatorId = userInfo.Id;
                Blog editedBlog = _bservice.Edit(editData);
                return(Ok(editedBlog));
            }
            catch (System.Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
Beispiel #7
0
        public async Task <ActionResult <Blog> > Edit(int id, [FromBody] Blog editBlog)
        {
            try
            {
                Profile userInfo = await HttpContext.GetUserInfoAsync <Profile>();

                editBlog.CreatorEmail = userInfo.Email;
                editBlog.Creator      = userInfo;
                editBlog.Id           = id;

                return(Ok(_serv.Edit(editBlog, userInfo.Email)));
            }
            catch (System.Exception error)
            {
                return(BadRequest(error.Message));
            }
        }