public IActionResult Put(int id, UserPoseDifficulty userPoseDifficulty) { if (id != userPoseDifficulty.Id) { return(BadRequest()); } var currentUser = GetCurrentUserProfile(); userPoseDifficulty.UserProfileId = currentUser.Id; _userPoseDifficultyRepository.Update(userPoseDifficulty); return(NoContent()); }
public IActionResult Post(UserPoseDifficulty userPoseDifficulty) { var currentUser = GetCurrentUserProfile(); userPoseDifficulty.UserProfileId = currentUser.Id; var existingUserPoseDifficulty = _userPoseDifficultyRepository .GetByPoseIdAndUserProfileId(userPoseDifficulty.PoseId, userPoseDifficulty.UserProfileId); if (existingUserPoseDifficulty == null) { _userPoseDifficultyRepository.Add(userPoseDifficulty); return(CreatedAtAction("Get", new { id = userPoseDifficulty.Id }, userPoseDifficulty)); } else { _userPoseDifficultyRepository.Delete(existingUserPoseDifficulty.Id); _userPoseDifficultyRepository.Add(userPoseDifficulty); return(CreatedAtAction("Get", new { id = userPoseDifficulty.Id }, userPoseDifficulty)); } }
public void Update(UserPoseDifficulty userPoseDifficulty) { _context.Entry(userPoseDifficulty).State = EntityState.Modified; _context.SaveChanges(); }
public void Add(UserPoseDifficulty userPoseDifficulty) { _context.Add(userPoseDifficulty); _context.SaveChanges(); }