public async Task <IActionResult> PutSystemSettingGroup([FromRoute] int id, [FromBody] SystemSettingGroup systemSettingGroup)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != systemSettingGroup.ID)
            {
                return(BadRequest());
            }

            _context.Entry(systemSettingGroup).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SystemSettingGroupExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
예제 #2
0
 public Task Delete(SystemSettingGroup systemSettingGroup, CancellationToken cancellationToken)
 {
     if (_context.SystemSettingGroups.Contains(systemSettingGroup))
     {
         _context.SystemSettingGroups.Remove(systemSettingGroup);
         _context.SaveChanges();
     }
     return(Task.CompletedTask);
 }
예제 #3
0
        public Task <SystemSettingGroup> Update(SystemSettingGroup systemSettingGroup, CancellationToken cancellationToken)
        {
            var existingSystemSettingGroup = _context.SystemSettingGroups.FirstOrDefault(x => x.Id == systemSettingGroup.Id);

            existingSystemSettingGroup.Name        = systemSettingGroup.Name;
            existingSystemSettingGroup.Description = systemSettingGroup.Description;
            existingSystemSettingGroup.Order       = systemSettingGroup.Order;
            existingSystemSettingGroup.ModifiedBy  = systemSettingGroup.ModifiedBy;
            existingSystemSettingGroup.ModifiedAt  = systemSettingGroup.ModifiedAt;
            _context.SaveChanges();
            return(Task.FromResult(existingSystemSettingGroup));
        }
        public async Task <IActionResult> PostSystemSettingGroup([FromBody] SystemSettingGroup systemSettingGroup)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.SystemSettingGroup.Add(systemSettingGroup);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetSystemSettingGroup", new { id = systemSettingGroup.ID }, systemSettingGroup));
        }
예제 #5
0
 public Task <SystemSettingGroup> Add(SystemSettingGroup systemSettingGroup, CancellationToken cancellationToken)
 {
     _context.SystemSettingGroups.Add(systemSettingGroup);
     _context.SaveChanges();
     return(Task.FromResult(systemSettingGroup));
 }