Ejemplo n.º 1
0
        public async Task <ApiResponse> DeleteUserAsync(int userID)
        {
            var user = await _dbContext.Users.Where(u => u.UserID == userID).SingleOrDefaultAsync();

            if (user != null)
            {
                _dbContext.Users.Remove(user);
                _dbContext.SaveChanges();
                return(new ApiResponse {
                    Message = $"User deleted successfully with id {userID}", StatusCode = StatusCode.Ok
                });
            }
            else
            {
                return(new ApiResponse {
                    Message = $"User not found with id {userID}", StatusCode = StatusCode.NotFound
                });
            }
        }
Ejemplo n.º 2
0
        public async Task <ApiResponse> DeleteTestAsync(int testID)
        {
            var test = await _dbContext.Tests.Where(t => t.TestID == testID).SingleOrDefaultAsync();

            if (test != null)
            {
                _dbContext.Tests.Remove(test);
                _dbContext.SaveChanges();
                return(new ApiResponse {
                    Message = $"Test deleted successfully with id {testID}", StatusCode = StatusCode.Ok
                });
            }
            else
            {
                return(new ApiResponse {
                    Message = $"Test not found with id {testID}", StatusCode = StatusCode.NotFound
                });
            }
        }
Ejemplo n.º 3
0
        public async Task <ApiResponse> DeletePatientAsync(int patientID)
        {
            var patient = await _dbContext.Patients.Where(t => t.PatientID == patientID).SingleOrDefaultAsync();

            if (patient != null)
            {
                _dbContext.Patients.Remove(patient);
                _dbContext.SaveChanges();
                return(new ApiResponse {
                    Message = $"Patient deleted successfully with id {patientID}", StatusCode = StatusCode.Ok
                });
            }
            else
            {
                return(new ApiResponse {
                    Message = $"Patient not found with id {patientID}", StatusCode = StatusCode.NotFound
                });
            }
        }