public async Task <WeightCategoryGroup> AddWeightCategoryGroupAsync(WeightCategoryGroup wightCategoryGroup) { _context.Add(wightCategoryGroup); await _context.SaveChangesAsync(); return(wightCategoryGroup); }
public async Task <WeightCategoryGroup> UpdateWeightCategoryGroupAsync(WeightCategoryGroup group, string userId) { var stored = await GetWeightCategoryGroupAsync(group.Id, userId); stored.Name = group.Name; _context.Update(stored); await _context.SaveChangesAsync(); return(stored); }
public async Task<IActionResult> UpdateWeightCategoryGroup([FromBody] WeightCategoryGroup group) { try { var userId = User.Identity.Name; group = await _organizerService.UpdateWeightCategoryGroupAsync(group, userId); return Ok(group); } catch (Exception ex) { return BadRequest(ex.Message); } }
public async Task<IActionResult> AddWeightCategoryGroup([FromBody] WeightCategoryGroup weightCategoryGroup) { try { var userId = User.Identity.Name; weightCategoryGroup.ApplicationUserId = userId; weightCategoryGroup = await _organizerService.AddWeightCategoryGroupAsync(weightCategoryGroup); return Ok(weightCategoryGroup); } catch (Exception ex) { return BadRequest(ex.Message); } }