[HttpPost("finalize")] //Marks requests as completed and update the current users keystore
        public async Task <IActionResult> FinalizeRequests([FromBody] FinalizeRequestApiModel model)
        {
            var user = await _context.Users.FindAsync(User.Identity.Name);

            if (user == null)
            {
                return(Json(new { result = false }));
            }

            user.KeyStore = model.KeyStore;

            foreach (var requestId in model.RequestIds)
            {
                var request = await _context.Requests.FindAsync(Guid.Parse(requestId));

                if (request != null)
                {
                    request.Completed = true;
                }
            }
            await _context.SaveChangesAsync();

            return(Json(new { result = true }));
        }
        public async Task <IActionResult> Create([FromBody] UserApiModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new User
                {
                    Name          = model.Name,
                    NewIdentifier = model.Identifier,
                    PublicKey     = model.PublicKey,
                    KeyStore      = model.KeyStore
                };
                _context.Users.Add(user);
                await _context.SaveChangesAsync();

                return(Json(new { result = true }));
            }
            return(Json(new { result = false }));
        }