public async Task <IActionResult> PutFeatureRequestItem([FromRoute] string id, [FromBody] FeatureRequestItem featureRequestItem) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != featureRequestItem.Id) { return(BadRequest()); } _context.Entry(featureRequestItem).State = EntityState.Modified; try { featureRequestItem.LastEditDate = DateTime.Now; await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!FeatureRequestItemExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> AddFeatureRequestItemToAccount([FromBody] AppUserViewModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } ClaimsPrincipal currentUser = User; var currentUserName = currentUser.FindFirst(ClaimTypes.NameIdentifier).Value; AppUser user = await _userManager.FindByNameAsync(currentUserName); _appDbContext.Users.Attach(user); user.FeatureRequestItems = model.FeatureRequestItems; _appDbContext.Entry(user).Collection("FeatureRequestItems").IsModified = true; _appDbContext.SaveChanges(); return(new OkObjectResult(user)); }