Esempio n. 1
0
        public async Task <IActionResult> DeleteUser(int userId)
        {
            try
            {
                Data.Entities.User dbUser = await _repository.GetUserAsync(userId);

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

                _repository.Delete <Data.Entities.User>(dbUser);
                await _repository.SaveChangesAsync();

                return(NoContent());
            }
            catch (Exception ex)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, "Database exception: " + ex.Message));
            }
        }
        public async Task <IActionResult> DeleteMuscleGroup(int muscleGroupId)
        {
            try
            {
                Data.Entities.MuscleGroup dbMuscleGroup = await _repository.GetMuscleGroupAsync(muscleGroupId);

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

                _repository.Delete <Data.Entities.MuscleGroup>(dbMuscleGroup);
                await _repository.SaveChangesAsync();

                return(NoContent());
            }
            catch (Exception ex)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, "Database exception: " + ex.Message));
            }
        }
Esempio n. 3
0
        public async Task <IActionResult> DeleteBook(int bookId)
        {
            try
            {
                Data.Entities.Book dbBook = await _repository.GetBookAsync(bookId);

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

                _repository.Delete <Data.Entities.Book>(dbBook);
                await _repository.SaveChangesAsync();

                return(NoContent());
            }
            catch (Exception ex)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, "Database exception: " + ex.Message));
            }
        }
Esempio n. 4
0
        public async Task <IActionResult> DeleteRefreshToken(int tokenId)
        {
            try
            {
                Data.Entities.RefreshToken dbRefreshToken = await _repository.GetRefreshTokenAsync(tokenId);

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

                _repository.Delete <Data.Entities.RefreshToken>(dbRefreshToken);
                await _repository.SaveChangesAsync();

                return(NoContent());
            }
            catch (Exception ex)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, "Database exception: " + ex.Message));
            }
        }
        public async Task <IActionResult> DeleteJob(short jobId)
        {
            try
            {
                Data.Entities.Job dbJob = await _repository.GetJobAsync(jobId);

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

                _repository.Delete <Data.Entities.Job>(dbJob);
                await _repository.SaveChangesAsync();

                return(NoContent());
            }
            catch (Exception ex)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, "Database exception: " + ex.Message));
            }
        }
        public async Task <IActionResult> DeleteStore(string storeId)
        {
            try
            {
                Data.Entities.Store dbStore = await _repository.GetStoreAsync(storeId);

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

                _repository.Delete <Data.Entities.Store>(dbStore);
                await _repository.SaveChangesAsync();

                return(NoContent());
            }
            catch (Exception ex)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, "Database exception: " + ex.Message));
            }
        }