public async Task <ActionResult> Update_Desc_ByID(int id, UserDescriptionDTO desc) { if (!DescExists(id)) { return(BadRequest(new { message = "Description not found." })); } else { var _desc = _context.UserDescription.SingleOrDefault(x => x.Id == id); _desc.Description = desc.Description; await _context.SaveChangesAsync(); return(Ok("User description has been updated!")); } }
public async Task <ActionResult> Update_Desc(UserDescriptionDTO desc) { //Finding who is logged in int logged_id = int.Parse(User.Identity.Name); var _desc = _context.UserDescription.SingleOrDefault(x => x.UserId == logged_id); if (_desc == null) { return(BadRequest(new { message = "There is no description linked to your account" })); } _desc.Description = desc.Description; await _context.SaveChangesAsync(); return(Ok("User description has been updated!")); }