public async Task <ActionResult <Service> > Post([FromBody] Service value)
        {
            if (value != null && value.Key != null)
            {
                var service = _toggleContext.Services.Where(s => s.Key == value.Key).FirstOrDefault();
                if (service != null)
                {
                    return(CreatedAtAction(nameof(Get), new { id = service.Id }, service));
                }
            }
            _toggleContext.Services.Add(value);
            await _toggleContext.SaveChangesAsync();

            return(CreatedAtAction(nameof(Get), new { id = value.Id }, value));
        }
Exemplo n.º 2
0
        public async Task <ActionResult <Toggle> > Post([FromBody] Toggle value)
        {
            if (value != null && value.Key != null)
            {
                var toggle = _toggleContext.Toggles.Where(t => t.Key == value.Key).FirstOrDefault();
                if (toggle != null)
                {
                    return(CreatedAtAction(nameof(Get), new { id = toggle.Id }, toggle));
                }
            }
            _toggleContext.Toggles.Add(value);
            await _toggleContext.SaveChangesAsync();

            return(CreatedAtAction(nameof(Get), new { id = value.Id }, value));
        }
Exemplo n.º 3
0
        public async Task <ActionResult <ToggleState> > Post([FromBody] ToggleState value)
        {
            var toggleState = _toggleContext.States
                              .Where(state => state.ToggleId == value.ToggleId)
                              .Where(state => state.ServiceId == value.ServiceId)
                              .FirstOrDefault();

            if (toggleState != null)
            {
                return(CreatedAtAction(nameof(Get), new { id = toggleState.Id }, toggleState));
            }
            _toggleContext.States.Add(value);
            await _toggleContext.SaveChangesAsync();

            return(CreatedAtAction(nameof(Get), new { id = value.Id }, value));
        }