public async Task <IActionResult> PutUserInfo([FromBody] UserInfo userInfo) { var claims = HttpContext.User.Claims; var id = claims.FirstOrDefault(x => x.Type == "Id")?.Value; var currentUserInfo = await _context.UserInfo.FirstOrDefaultAsync(info => info.UserId == id); currentUserInfo.UserPhone = userInfo.UserPhone; currentUserInfo.UserSex = userInfo.UserSex; currentUserInfo.UserBirthday = userInfo.UserBirthday; _context.Entry(currentUserInfo).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserInfoExists(currentUserInfo.Id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutProduct(int id, Product product) { if (id != product.Id) { return(BadRequest()); } _context.Entry(product).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProductExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }