public IActionResult UpdateBlogImage(UpdatelogImage updatelogImage) { if (!ModelState.IsValid) { return(BadRequest("Enter the correct values")); } var(result, succeeded) = _commonServices.UpdateBlogImage(updatelogImage); if (succeeded) { return(Ok(result)); } return(BadRequest(result)); }
public (JsonResult result, bool Succeeded) UpdateBlogImage(UpdatelogImage updatelogImage) { try { BlogImage blogImg = _context.BlogImages.FirstOrDefault(p => p.ImageURL == updatelogImage.ImageURL); _context.Entry(blogImg).CurrentValues.SetValues(updatelogImage); if (_context.SaveChanges() == 1) { return(new JsonResult("Blog Description updated successfully."), true); } else { return(new JsonResult("Enter the correct values."), false); } } catch (Exception ex) { return(new JsonResult("Some server error occured. Please try again!!"), false); } }