Ejemplo n.º 1
0
        public async Task <IActionResult> Update([FromBody] PostDto model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var update = await _postServices.GetPostByID(model.ID);

                    if (update != null)
                    {
                        await _postServices.UpdatePost(model);

                        return(Ok($"{model.Title} updated Successfully"));
                    }
                }
                return(BadRequest("Update failed, Please try again"));
            }
            catch (Exception ex)
            {
                return(BadRequest($"{ex.Message}, Error! Your task failed, Please try again"));
            }
        }