Exemplo n.º 1
0
        public async Task <AgeCategoryGroup> AddAgeCategoryGroupAsync(AgeCategoryGroup ageCategoryGroup)
        {
            _context.Add(ageCategoryGroup);
            await _context.SaveChangesAsync();

            return(ageCategoryGroup);
        }
Exemplo n.º 2
0
        public async Task <AgeCategoryGroup> UpdateAgeCategoryGroupAsync(AgeCategoryGroup group, string userId)
        {
            var stored = await GetAgeCategoryGroupAsync(group.Id, userId);

            stored.Name = group.Name;
            _context.Update(stored);
            await _context.SaveChangesAsync();

            return(stored);
        }
 public async Task<IActionResult> UpdateAgeCategoryGroup([FromBody] AgeCategoryGroup group)
 {
     try
     {
         var userId = User.Identity.Name;
         group = await _organizerService.UpdateAgeCategoryGroupAsync(group, userId);
         return Ok(group);
     }
     catch (Exception ex)
     {
         return BadRequest(ex.Message);
     }
 }
 public async Task<IActionResult> AddAgeCategoryGroup([FromBody] AgeCategoryGroup ageCategoryGroup)
 {
     try
     {
         var userId = User.Identity.Name;
         ageCategoryGroup.ApplicationUserId = userId;
         ageCategoryGroup =  await _organizerService.AddAgeCategoryGroupAsync(ageCategoryGroup);
         return Ok(ageCategoryGroup);
     }
     catch(Exception ex)
     {
         return BadRequest(ex.Message);
     }
 }