Ejemplo n.º 1
0
        public IActionResult DeleteBot([FromBody] BotOptionApi option)
        {
            if (option == null)
            {
                return(BadRequest());
            }

            if (option.Id == null)
            {
                return(BadRequest());
            }

            var dbOption = _options.Get(new BotOptions()
            {
                Id = option.Id
            });

            if (dbOption == null)
            {
                return(NotFound());
            }

            try
            {
                _options.Remove(dbOption);
            }
            catch (Exception e)
            {
                return(StatusCode(500));
            }

            return(Ok());
        }
Ejemplo n.º 2
0
        public IActionResult SetProfiles([FromBody] BotOptionApi option)
        {
            if (option == null)
            {
                return(BadRequest());
            }

            if (string.IsNullOrWhiteSpace(option.Name))
            {
                return(BadRequest());
            }

            var tempOption = _options.Add(option);

            option.Profiles.ForEach(profile =>
            {
                if (profile.Occurrence == null)
                {
                    profile.Occurrence = 1;
                }

                if (profile.Occurrence > 0)
                {
                    var p = _profiles.Get(profile);

                    if (p != null)
                    {
                        tempOption.AddProfile(p, profile.Occurrence.Value);
                    }
                }
            });

            _options.Update(tempOption);

            return(Ok());
        }