Exemple #1
0
        public IActionResult DeleteKeysBySelect([FromBody] List <KeyDto> keys)
        {
            try
            {
                var res = _keysService.DeleteKeysBySelect(keys);

                if (res == false)
                {
                    var errMessage = new { success = res, message = "No key selected" };

                    return(NotFound(errMessage));
                }

                var deletedKeys = $"{res}";

                var message = new { success = res, message = $"Successfully deleted {keys.Count} keys" };

                return(Ok(message));
            }
            catch (Exception e)
            {
                return(BadRequest(e));
            }
        }
Exemple #2
0
        public IActionResult DeleteKeysBySelect([FromQuery] string selection = "keys2delete")
        {
            try
            {
                if (selection == null)
                {
                    return(BadRequest(ModelState));
                }

                if (!_keysService.DeleteKeysBySelect(selection))
                {
                    ModelState.AddModelError("", $"Something went wrong seting key pair value");
                    return(StatusCode(500, ModelState));
                }

                var message = new { success = true, message = $"Successfully deleted items" };

                return(Ok(message));
            }
            catch (Exception e)
            {
                return(BadRequest(e));
            }
        }