Beispiel #1
0
        public async Task <ActionResult <int> > DropDatabase([FromForm] string hash)
        {
            try
            {
                if (!User.IsAdmin(userRepository))
                {
                    throw new Exception(localizer[Controllers_AdminController.Only_admin_is_allowed_to_drop_database].Value);
                }

                var drop = await userRepository.DropDatabaseAuthorize(User.GetEmail(), hash);

                if (!drop)
                {
                    throw new Exception(localizer[Controllers_AdminController.Invalid_user_or_password].Value);
                }

                var ret = 0;
                ret += await placeRepository.DropAllData();

                ret += await slotRepository.DropAllData();

                ret += await visitorRepository.DropAllData();

                ret += await userRepository.DropAllData();

                ret += await placeProviderRepository.DropAllData();

                return(Ok(ret));
            }
            catch (Exception exc)
            {
                logger.LogError(exc, exc.Message);

                return(BadRequest(new ProblemDetails()
                {
                    Detail = exc.Message
                }));
            }
        }