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()); }
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()); }